in reply to script that logs and deletes old windows files
I like to use the core module Time::Local to check for time differences.
use Time::Local qw( timelocal_nocheck ); my ($mday, $mon, $year) = (localtime())[3, 4, 5]; my $five_days_ago = timelocal_nocheck(0, 0, 0, $mday-5, $mon, $year); foreach my $filename (...) { next unless (stat($filename))[9] < $five_days_ago; ...do something... }
|
|---|