If you're concerned about stuffed directories producing huge in-memory lists or arrays, opendir will give you a handle you can read one name at a time. Since you are looking for maximum times, you can keep memory requirements low and independent of population.

Your requirement for a creation time is tougher because it's not a portable statistic. Unix filesystems don't have any such thing. Think about that requirement, though. Is the intent to advertise newest content? Then an edited file ought to be as good as a newly uploaded one. In that case, mtime is what you want, and it is quite portable.

System touch and Perl utime can alter file times, and touch can create empty files. Filesystem time stamps should not be regarded as definitive of anything.

You should take a look at File::Find. It's not the easiest thing to use, but it can handle any problem of this kind.

Update: ++davido's solution is best if you know that all uploads come in through your script. With shell or ftp access in the mix, you'd need to do a lot of maintainance in cron jobs.

After Compline,
Zaxo


In reply to Re: efficient way to find most recently modified files? by Zaxo
in thread efficient way to find most recently modified files? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.