http://qs321.pair.com?node_id=277224

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 ); }