Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get the time when the file is modified in perl

Posted on 2006-06-14
5
Medium Priority
?
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

722 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