Stephan Hochhaus wrote:
> Hello list,
> 
> I tried to dig my way through my newly acquired Perl ina nutshell and
> Learning Perl, but I couldn't find a satisfying solution to my
> problem: 
> 
> How can I print the last modification date of a file? It should work
> on different systems (*nix and OS X, Win32 is nice to have but not a
> mus). Any pointers to a solution are very welcome!

The stat() function returns a list of information about a file, including
the modification timestamp. This value is in epoch seconds. You can convert
it to a printable date using localtime() or gmtime():

   $mtime = (stat "/etc/passwd")[9];
   print scalar localtime $mtime;

This will work on all the platforms you listed. If you want more control
over the formatting, consider using POSIX strftime() function.

perldoc -f stat
perldoc -f localtime
perldoc -f gmtime
perldoc POSIX

HTH

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to