If you need the timediff's only then why not create a separate marker file and with -M you can get the age of the file in seconds? note, that "age" is actually the age in seconds from the moment the perl script started, so if you use a daemon, it will not work, however, if your script starts regularly or on-demand, this works:

#!/usr/bin/perl use strict; use warnings; my $TESTFILE='/tmp/x'; unless (-f $TESTFILE){ open(TF, '>',$TESTFILE) or die $!; close(TF); } my $AGE_seconds = -r $TESTFILE ? int( (-M _) *60*60*24) : -1; print "the file $TESTFILE is $AGE_seconds seconds old.\n";

As for the timelocal(), roll your own, with a simple regular expression you are all set. Just be careful to not match a date in the other fields.


In reply to Re: Converting a date to a string and back by FreeBeerReekingMonk
in thread Converting a date to a string and back by JonesyJones

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.