in reply to Help e-mailing last 50 lines of log file
This will read a file backwards untill yestersdays date. If your log file is large try file::Readbackwards.
Recommended by runrig
If the log file is large (which log files sometimes tend to be) then you might want to use File::ReadBackwards or risk getting an 'Out of memory' error.
I hope that helps.
Sam
Or you can try this...my $file; my @lines; open FH, 'yourlogfile.log'; @lines = <FH>; LINE: while ($file = pop @lines) { if ( $file =~ m/^ERR*/ ) { print "$file\n"; } last LINE if ($file !~ m/^$today*/ && $file =~ m/^(\S+\s+\S+\s+\d+)\s+\d+:\d+:\d+\s+(\d+)/x ); }
Recommended by runrig
If the log file is large (which log files sometimes tend to be) then you might want to use File::ReadBackwards or risk getting an 'Out of memory' error.
I hope that helps.
Sam
In Section
Seekers of Perl Wisdom