in reply to Re: How to Know how much old my file is
in thread How to Know how much old my file is

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

Replies are listed 'Best First'.
Re^3: How to Know how much old my file is
by Discipulus (Canon) on Sep 15, 2015 at 07:53 UTC
    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.