$mod = (stat "$path/$filename")[9];
# this prints result in usual date format
# like -> Tue Jun 12 23:50:10 2001
print scalar localtime $mod;
If you use Super Search you will find heaps of examples on this topic floating around the monastery. This is also in the Perl FAQ at How do I get a file's timestamp in perl?. If you have not discoverd the Perl FAQ you are missing out on heaps of goodies.
cheers
tachyon
| [reply] [Watch: Dir/Any] [d/l] |
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 | [reply] [Watch: Dir/Any] [d/l] |
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 | [reply] [Watch: Dir/Any] [d/l] |