in reply to Need a script to identify a given string in a log file

My recommended approach:

For ordering your files you could possibly do the following:

my @files = glob( "/var/log/messages*" ); # sort by mtime my @sortedfiles = sort { ( stat($b) )[9] <=> ( stat($a) )[9] } @files;

You could, of course, attempt to start from the tail of the log file and work your way backwards, but that is very hard work and may be an unnecessary optimisation.