in reply to Re^2: Deleting a Temp File
in thread Deleting a Temp File

Look at "perldoc -f -X", especially "-M" -- that reports the age of the file in days (a floating point number) relative to the time that the script started. (It's actually based on the date and time of "last modification" of the file, not "creation", but that shouldn't make any difference for you.)

Also, File::Find (or anything related to it) is overkill if you just have one directory (no subdirectories) where the temp files are kept:

# get a list of data files that are at least one day old in /my/tmpdir +: opendir( TMP, "/my/tmpdir" ); my @dayold = grep { /[^.]/ and -f and -M _ > 1 } readdir TMP; closedir TMP; # don't like old files? kill 'em off: unlink map { "/my/tmpdir/$_" } @dayold;
If you want to focus on files that are, say, just 2 hours old or older, use "2/24" instead of "1" to test against the value of "-M".