DelphiFAQ Home Search:

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

 

comments1 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

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";

Comments:

2007-03-28, 05:48:13
anonymous  
rating
Appear to work only for Local files? How about remote server files?

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.