http://qs1969.pair.com?node_id=183094


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.
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 ); }
Or you can try this...
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