in reply to How to Know how much old my file is

Hello,
is better to use Perl functions when they are! in this case stat is your tool. Modification time is the 9th element of the array returened by that function. Pay some attention to returned time value because they are expressed in seconds from epoch.
Additionally you must be aware of some modification needed, for example, to years (add 1900). see the docs for the localtime function.

Be aware of do not using the module(update 16 Sep) to understand the differences between the builtin function and the module: infact the module override the stat function and export a object oriented interface: see Problem with file::stat and Re: File date.

HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: How to Know how much old my file is
by Anonymous Monk on Sep 15, 2015 at 07:20 UTC

    is better to use Perl functions when they are! ...Be aware of do not using the module: see Problem with file::stat and Re: File date.

    stat is like readdir, its low level, not very memorable, and easy to forget to do your own error checking

    Path::Tiny makes life very conveniently memorable and brings in File::stat

    $ perl -le " print scalar gmtime( ( stat shift )[9] ) " Thu Jan 1 00:00:00 1970 $ perl -le " print scalar gmtime( ( stat shift )[9] ) " . Tue Sep 15 07:20:27 2015 $ perl -le " print scalar gmtime( ( stat shift )[9] ) " .. Fri May 29 06:13:23 2009 $ perl -le "use Path::Tiny; print scalar gmtime( path( shift )->stat-> +mtime ) " Path::Tiny paths require defined, positive-length parts at -e line 1. $ perl -le "use Path::Tiny; print scalar gmtime( path( shift )->stat-> +mtime ) " . Tue Sep 15 07:20:27 2015 $ perl -le "use Path::Tiny; print scalar gmtime( path( shift )->stat-> +mtime ) " .. Fri May 29 06:13:23 2009
      yes you are somehow right. I just not explored yet the possibility of using Path::Tiny even if i have eard very well about it. Anyway i do not dislike the use of low levels: they are the foundamentals, usefull to know and understand, imho.
      perl -e "print scalar localtime((stat $ARGV[0])[9])" . Mon Jul 27 09:30:25 2015

      L*
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.