in reply to Comparing time and date stamps

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