Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: extract last 1 min log and find a string

by Laurent_R (Canon)
on Jul 20, 2017 at 17:18 UTC ( [id://1195638]=note: print w/replies, xml ) Need Help??


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

AFAIK, File::ReadBackwards is a pure Perl module. You should be able to install it manually. There may be a couple of additional dependencies, but it should not be too difficult. What type of failure do you encounter?
  • Comment on Re: extract last 1 min log and find a string

Replies are listed 'Best First'.
Re^2: extract last 1 min log and find a string
by ytjPerl (Scribe) on Jul 20, 2017 at 17:27 UTC

    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!

      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.
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-19 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found