Like, I *love* Date::Manip, that's just me I lllllike it. But if you don't have holidays inputted correctly (especially if you aren't in the U.S.) or hey they added another holiday, well you only have 9 files.

So why not just keep 13 or 14 files? Is each one so huge that you are going to wreck your partition? Laziness is a virtue in Perl and saves you time too. I'm going to stick to that and not post any code! :)

Also, I would say don't worry so much about dates. You have a process that is generating a file a day, *if* it's running. Count how many files you have in the directory once a day and unlink the last one. You might even be able to parse the file names to be sure, because what if someone touches one, or you do a recovery from backup. If these are important files look at what is the easiest way to ensure your integrity.

The easiest way I can think of doing that if you are in control of file naming is to name files in sequential order, sort the file names, and determine the next file number. Perhaps you could even use time(). Otherwise if you are really sure you want to get rid of the oldest file, -M or stat will do the age checking part (in unix anyway, don't quote me for Windows).


In reply to Re: find "x" quantity newest files in a dir by mattr
in thread find "x" quantity newest files in a dir by braintoast

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.