Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

How do I determine file creation or last-access date?

by rupesh (Hermit)
on Jul 23, 2003 at 16:01 UTC ( #277224=perlquestion: print w/replies, xml ) Need Help??

rupesh has asked for the wisdom of the Perl Monks concerning the following question: (files)

Is there a way to find out when a file was created/last accessed, just like one would get to see while doing a ls-l or dir in DOS?

Originally posted as a Categorized Question.

  • Comment on How do I determine file creation or last-access date?

Replies are listed 'Best First'.
Re: File Date
by The Mad Hatter (Priest) on Jul 23, 2003 at 16:05 UTC
    See perldoc -f stat and perldoc -f -X.
Re: File Date
by draconis (Scribe) on Jul 23, 2003 at 20:34 UTC
    Perl's stat() is a great function for extracting file specific info!
Re: How do I determine file creation or last-access date?
by amitbhosale (Acolyte) on Feb 13, 2008 at 10:20 UTC

    The ctime() function provides a way of getting at the scalar sense of the original CORE::localtime() function.

    use Time::localtime; use File::stat; for ( @ARGV ) { print "\nFile: $_"; print "\n Last access time: ", ctime( stat($_)->atime ); print "\n Last modify time: ", ctime( stat($_)->mtime ); print "\n File creation time: ", ctime( stat($_)->ctime ); }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://277224]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2023-03-23 07:23 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.