in reply to Re: extract last 1 min log and find a string
in thread extract last 1 min log and find a string

Please refer to the question I asked about .pm module location. "Can't locate File::/ReadBackwards.pm in @INC<@INC contains: D:/App/Perl/site/lib D:/App/Perl/lib.> I already did that. Thanks!

  • Comment on Re^2: extract last 1 min log and find a string

Replies are listed 'Best First'.
Re^3: extract last 1 min log and find a string
by poj (Abbot) on Jul 20, 2017 at 17:37 UTC

    You need to put the file ReadBackwards.pm in D:/App/Perl/site/lib/File. Create a sub folder File if necessary

    How big is the log file ? Gigabytes ?

    poj
      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.
Re^3: extract last 1 min log and find a string
by Laurent_R (Canon) on Jul 20, 2017 at 18:47 UTC
    Yes, I saw that other question only after I saw this one and replied to it, but since it had the correct answer that you needed to create a File subdirectory, I did not think it was useful to further comment on that other question.