Your current time and date stamp are fine with a little manipulation. First you can drop all to punctuation the to leave just the digits. So 2007-11-10-07:09:52 becomes 20071110070952, not as nice to the eye, but OS safe, a little more compact, easy to parse and easy to compare.

Tacking the stamp onto the end of the file extension is somewhat sub optimum. Better to tack it onto the file name part: test_20071110070952.pl where it doesn't hide the extension in the middle of a large file name.

Having done all that you need to be able to isolate the stamp to make it easy to compare. A simple regex does that:

my ($timestamp) = $filename =~ /_(\d{14})\b/;

Then a simple cmp, gt, lt, ge, le, eq or ne between the two timestamps does the job.


Perl is environmentally friendly - it saves trees

In reply to Re: Comparing time and date stamps by GrandFather
in thread Comparing time and date stamps by ewhitt

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.