-M Script start time minus file modification time, in days

172 Views Asked by At

I would expect -M $_ to be negative, but it is zero for:

perl -E 'qx(touch $_), sleep(5), say -M for "/tmp/file"'

Does perldoc mentions such behavior?

1

There are 1 best solutions below

0
On BEST ANSWER

I think this explains what you are seeing

perl -E 'say "START TIME",$^T; qx(touch $_), sleep(5), say -M for "/tmp/file"; say "STAT ON FILE", (stat(_))[9]'

output when I ran it

START TIME1434460114
0
STAT ON FILE1434460114

1) script starts $^T is set to 1434460114

2) almost immediately the file "/tmp/file" is made with a modify time of 1434460114

3) sleep for 5 seconds

4) -M reports the difference of the modify time on the file and the script start time as zero

try this instead

perl -E 'say "START TIME",$^T;  sleep(5),qx(touch $_), say -M for "/tmp/file"; say "STAT ON FILE", (stat(_))[9]'

output on my system

START TIME1434460296
-5.78703703703704e-05
STAT ON FILE1434460301