in reply to Re^2: efficient way to find most recently modified files?
in thread efficient way to find most recently modified files?

OK, this is untested, but try something like:

my @files_sorted = sort { substr($a,-14,10) cmp substr($b,-14,10) } (g +lob('yourpath/bobby*.txt')); my $latest_file = $files_sorted[-1];

This assumes that all '.txt' files have the name format you mention.

Cheers

mildside

Replies are listed 'Best First'.
Re^4: efficient way to find most recently modified files?
by mildside (Friar) on May 08, 2006 at 06:24 UTC
    Actually, if all your 'bobby*.txt' files follow your filenaming convention then the sort can be expressed a little bit simpler as (untested):

    my @files_sorted = sort (glob('yourpath/bobby*.txt')); my $latest_file = $files_sorted[-1];

    Cheers

    mildside