http://www.perlmonks.org?node_id=87916

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Posting file's modification date?
by tachyon (Chancellor) on Jun 13, 2001 at 00:01 UTC
Re: Posting file's modification date?
by Eradicatore (Monk) on Jun 13, 2001 at 00:02 UTC
    You can use -M to find out the age of the file since the last modification. This is age in days like 6.5321421 etc.
    $age = -M $file;

    Justin Eltoft

    "If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

      There is a mod_perl gotcha here... The file test operators calculate their deltas based on the "scripts" starting time. Under normal situations this works fine, but with mod_perl it can cause problems, since the starting time may have been weeks ago. (leading to values such as "This file was modified -5.24 days ago") Resetting the $^T variable to the current time will fix this.
      $^T = time(); $age = -M $file;
      Of course, if it is straight CGI, you don't need to worry about it.

      -Blake