Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: File test to see creation time rather than last modified time

by almut (Canon)
on Feb 05, 2009 at 16:50 UTC ( #741602=note: print w/replies, xml ) Need Help??

in reply to File test to see creation time rather than last modified time

You could use stat():

if ( (time - (stat FILE)[10]) / (60*60*24) > 5 ) { ... }

Actually, as -M is "Script start time minus file modification time, in days", you'd have to store the return value of time() right at the beginning of the script, to get the exact equivalent for ctime... though I suppose the difference would be negligible.   (Update: actually (RTFM :) — use "perldoc -f -X" to get the docs for the filetests...) there even seems to be an option -C which does just that...)

Alternatively (Update2: and preferably — see kenneth/MidLifeXis's comments below), reset the modification time to what it was before, every time you make a modification...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://741602]
[usemodperl]: greetings
[usemodperl]: question
[usemodperl]: perldoc -v 'ARGV' works but perldoc -v "STDIN' does not, but they are both filehandles. is there a perldoc for STDIN?
[usemodperl]: (typo not withstanding :)
usemodperl thinks about loose coupling...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-06-19 19:15 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.