⭐ 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; }
|
|---|