in reply to Reading a log file
You're asking for more than a snippet there...
my $date = { set the date pattern you are looking for... } my $in_date = 0; while (my $line=<LOG>){ chomp $line; if ( ($in_date == 0 ) && ($line =~ m@SYNC@) && ($line =~ m@STARTED +@){ $line =~ s/\#//g; $line =~ s/^\s+//; $line =~ s/\s+$//; my @f=split(/\s+/,$line); shift @f; shift @f; my $rdate = join(" ",@f); if ( $date eq $rdate ) { $in_date=1; } } elsif ( $in_date && ($line =~ m@SYNC@ ) && ( $line =~ m@FINISHE +D@ ) ) { $in_date = 0; } elsif ( $line =~ m@HEFFILE@ ) { printf "%s\n",$line; } }
That's the basic gyst of it. You may want to tweak it and I won't guarantee there aren't bugs...
|
|---|