Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I delete files based on their timestamp?

by reptile (Monk)
on May 09, 2000 at 00:35 UTC ( #10662=note: print w/replies, xml ) Need Help??


in reply to How do I delete files based on their timestamp?

Or use perlfunc:stat from within perl. It'll give you just about everything you wanted to know about a file and more. The times returned are in seconds-since-epoch format just like time() so a little arithmetic and a comparison is all you need.

# delete $file if it's not been modified for 3 hours if ( (stat $file)[9] < time() - (3600 * 3) ) { unlink $file; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://10662]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-05-08 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (95 votes). Check out past polls.

    Notices?