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

lol, not homework...i just really want to do this for my little "member blog" site. just building stuff out of curiosity, which is how i sorta learn.
  • Comment on Re^2: efficient way to find most recently modified files?

Replies are listed 'Best First'.
Re^3: efficient way to find most recently modified files?
by mildside (Friar) on May 08, 2006 at 06:13 UTC
    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

      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