Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get the time when the file is modified in perl

Posted on 2006-06-14
5
Medium Priority
?
420 Views
Last Modified: 2010-04-17
Hi all,

How to get the time at which the file has be last modified in perl?
Thank you.
0
Comment
Question by:bladefish
5 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 252 total points
ID: 16904818
Quote: http://omaha.pm.org/emails/2003/msg00176.html     [Fwd: Daily Perl FAQ - How do I get a file's timestamp in perl?]
Question: How do I get a file's timestamp in perl?

    If you want to retrieve the time at which the file was last read,
    written, or had its meta-data (owner, etc) changed, you use the -M,
    -A, or -C filetest operations as documented in the perlfunc
    manpage. These retrieve the age of the file (measured against the
    start-time of your program) in days as a floating point number. To
    retrieve the "raw" time in seconds since the epoch, you would call
    the stat function, then use localtime(), gmtime(), or
    POSIX::strftime() to convert this into human-readable form.

    Here's an example:

        $write_secs = (stat($file))[9];
        printf "file %s updated at %s\n", $file,
            scalar localtime($write_secs);

    If you prefer something more legible, use the File::stat module
    (part of the standard distribution in version 5.004 and later):

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

    Error checking is left as an exercise for the reader.
<--
0
 
LVL 10

Assisted Solution

by:jagadeesh_motamarri
jagadeesh_motamarri earned 248 total points
ID: 16905142
Hi bladefish,

Well here some more variations of what you are looking for -

How to add the last date modified using Perl CGI - http://www.tdscripts.com/lastmodified.html

How can I put a Last modified date on my page using PERL - http://www.htmlforums.com/archive/index.php/t-2862.html

_____Jags.
0
 
LVL 4

Expert Comment

by:v_karthik
ID: 16908699
http://open.itworld.com/5040/nls_unix_fileattributes_060309/page_1.html

Gets you literally everything about the file.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Six Sigma Control Plans
Introduction to Processes

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question