DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

How do I get a file's date / timestamp in perl?

Question:

How do I get a file's date / timestamp in perl?

Answer:

For clean code, it is recommended to use File::stat module which is part of the standard distribution in version 5.004 and later.

Use method mtime() to get the last modification time. This is the time the file itself was modified last.

Instead you can also use stat.ctime which is the time directory information about the file was changed, not the file itself.

stat.atime is the last time the file was accessed.

use File::stat;
 use Time::localtime;
 
 $datetime_string = ctime(stat($file)->mtime);
 
 print "file $file was updated at $datetime_string\n";

Generated 4:01:32 on Aug 21, 2018