in reply to efficient way to find most recently modified files?

Please don't be offended, but is this homework?

Since at this stage I suspect it might be, I won't go into too much detail, but I suggest you look at glob and sort to start with.

mildside

  • Comment on Re: efficient way to find most recently modified files?

Replies are listed 'Best First'.
Re^2: efficient way to find most recently modified files?
by Anonymous Monk on May 08, 2006 at 06:02 UTC
    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.
      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