Thanks! it is working.
I have my codes as following:
use File::ReadBackwards;
use POSIX;
my $success;
my $items;
my $earliest = strftime( "%Y-%m-%d %H:%M:%S", localtime( time()- 1 * 6
+0 ) );
$bw = File::ReadBackwards->new( '/Documents/Traning/Perl/output.txt' )
+ or
die "/Documents/Traning/Perl/output.txt $!" ;
while ( defined( my $log_line = $bw->readline() ) ) {
last if $log_line lt $earliest;
if ($log_line =~ /EnableDelayedExpansion/i) {
print $log_line;
}else
{ print "error";}
}
My intention is to search the string in the logfile which is still loading every min, once I found string, print out this line. |