Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Parsing a specific section of a log file

by ysth (Canon)
on Feb 28, 2007 at 22:00 UTC ( [id://602610]=note: print w/replies, xml ) Need Help??


in reply to Parsing a specific section of a log file

I would do something like this (untested):
use File::ReadBackwards; use POSIX "strftime"; my $success; my $items; my $earliest = POSIX::strftime( "%Y-%m-%d %H:%M:%S", gmtime( time() - +30 * 60 ) ); $bw = File::ReadBackwards->new( 'log_file' ) or die "can't read 'log_file' $!" ; while ( defined( my $log_line = $bw->readline() ) ) { last if $log_line lt $earliest; $success ||= $log_line =~ /STATUS = SUCCESS/; $items ||= $log_line =~ /Found [1-9]\d* items to send/; last if $success && $items; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-25 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found