Click to See Complete Forum and Search --> : Last Modified On Script


bpagan
09-16-2004, 11:32 AM
I will be modifing a file on a regular basis (that will bee located on an HTML page, where users can download it), and rather than updating the HTML page to show the "last modified on" date of that file, I'd like a script that will automatically display the last time the file (not the HTML page) was updated.

Any thoughts?

Thanks

NogDog
09-16-2004, 11:44 AM
$stats = stat($filePathName);
print scalar localtime($stats[9]);

bpagan
09-16-2004, 11:54 AM
I'm new to Perl, where do I insert the code? And is there something similar for file size?

NogDog
09-16-2004, 01:49 PM
Originally posted by bpagan
I'm new to Perl, where do I insert the code? And is there something similar for file size?
The file size in bytes is another attribute returned by stat():
$stats = stat($filePathName);
printf ("<p>File: %s , size: %s bytes, last modified: %s</p>\n",
$filePathName,
$stats[7],
$stats[9]);
I'm afraid I'm not going to try to teach Perl and CGI programming in this response, however.