Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
laziness, impatience, and hubris
 
PerlMonks  

Posting file's modification date?

by Anonymous Monk
on Jun 12, 2001 at 19:47 UTC ( [id://87916]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

I am listing files in a Directory in a table on a web page. I want to post the Date Modified next to the name of the file. How do I capture the modified date of a file? beq_bruzek@yahoo.com

Replies are listed 'Best First'.
Re: Posting file's modification date?
by tachyon (Chancellor) on Jun 12, 2001 at 20:01 UTC
Re: Posting file's modification date?
by Eradicatore (Monk) on Jun 12, 2001 at 20: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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://87916]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.