in reply to jump lines in log file
#!/usr/bin/perl -w # # UNTESTED CODE # use strict; use warnings; open(FILE, "file.log") or die "$!"; my ($date,$found); while(my $line = <FILE>){ chomp; if (/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*$/){ # if match Date $date = $1; # set DATE }elsif ( /1st search for a string/ ){ # if match what i want $found = $line; } if($found){ print "$date:$found\n"; $found = undef; $date = undef; } } close(FILE);
|
|---|