#!/usr/bin/perl -w
use strict;
open (EVENTLOGFILE, "<eventlog.txt") || die("Could not open file eventlog file");
open (EVENTLOGFILE_NODATETIME, ">eventlog_nodatetime.txt") || die("Could not open new event log file");
my($line) = "";
while ($line = <EVENTLOGFILE>) {
my @fields = split /[ \t]/, $line;
my($newline) = "";
my($i) = 1;
foreach( @fields )
{
my($field) = $_;
if( $i ne 3 )
{
$newline = $newline . $field;
}
$i++;
}
print EVENTLOGFILE_NODATETIME "$newline";
}
close(EVENTLOGFILE);
close(EVENTLOGFILE_NODATETIME);
If I print out $line each time instead of $newline it can detect the encoding no problem. It's only when I try to modify the lines that it gets messed up.