Date: 2008may1
Language: perl
Keywords: moddate
Q. How can I get a file's modified date?
A. Here's how I do it:
sub getModDate($)
{
my($file) = @_;
my(@a) = stat($file);
if (scalar(@a) <= 0) { return undef; }
return $a[9];
}
# Example use:
use POSIX qw(strftime);
sub main()
{
$md = getModDate('/etc/passwd');
$md_str = strftime("%a %b %e %H:%M:%S %Y", localtime($md));
print "md=$md md_str=$md_str\n";
}
main();
| What this info useful to you? You can donate to say thanks |
Add a comment
Sign in to add a comment