in reply to Re^2: Getting the timestamp of a file
in thread Getting the timestamp of a file

$ ls -l monlog.txt -rw------- 1 h h 10755194 2008-05-30 12:59 monlog.txt $ perl -le 'print scalar localtime((stat)[9]) for @ARGV' monlog.txt Fri May 30 12:59:45 2008 $ perl -MFile::stat -le 'print scalar localtime(stat($_)->mtime) for @ +ARGV' monlog.txt Fri May 30 12:59:45 2008
Worked pretty well here. What do you mean with "i use the local time module to build a time function to tell me what time it is, and anytime the use::localtime module is active and i use the localtime function i get errors"?? If you have a local "localtime.pm" module, change its name and the name of the "faux-localtime" function, because it's not good practice to clobber core functions' names.
Update: used File::stat like becca23 did.
[]s, HTH, Massa (κς,πμ,πλ)

Replies are listed 'Best First'.
Re^4: Getting the timestamp of a file
by broomduster (Priest) on Jul 30, 2008 at 16:33 UTC
    In the hope of clearing some (potential) confusion here... I think becca23 is referring to Time::localtime (which is where ctime is defined), which is of course not the same as localtime. Nevertheless, using your one-liner, I get the same answer with both functions (which is a GoodThing).

    $ ls -l xyz.txt -rw-rw-r-- 1 x x 0 Jul 30 12:22 xyz.txt $ perl -le 'use Time::localtime; print ctime((stat)[9]) for @ARGV' xyz +.txt Wed Jul 30 12:22:28 2008 $ perl -le 'print scalar localtime((stat)[9]) for @ARGV' xyz.txt Wed Jul 30 12:22:28 2008
    ...still suspecting a time zone issue, but puzzled/worried by the 47 minute discrepancy, to say nothing of the approx 5 month discrepancy that comes with it...