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


in reply to Re: Reading from file- not change atime
in thread Reading from file- not change atime

Actually, you shouldn't load the module File::stat when you say (stat($fh))[8,9], because the module overrides the stat builtin, and the overridden stat returns an object providing methods such as atime, mtime, etc., instead of a list of values...

In other words, either simply don't use File::stat, or say something like

my $st = stat($fh) or die $!; my ($atime, $mtime) = ($st->atime, $st->mtime); ...

or even (if you like):

use File::stat ":FIELDS"; ... stat($fh) or die $!; my ($atime, $mtime) = ($st_atime, $st_mtime); ...

(Of course, you could also do away with the intermediate variables, and put the method calls directly in utime's argument list, i.e. utime($st->atime, $st->mtime, $fh), in case you're using File::stat).