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

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?


  • 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
    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
    STAT ON FILE1434460301