sub del_old{ my $age = 60*60*24*7; # convert 7 days into seconds my $now = time(); # get current time # Delete files older than 7 days. opendir (DIR, "old") or die "Couldn't open directory, $!"; while (my $file = readdir DIR) { next if $file=~/^\./; if ($now-(stat $file)[9] > $age) { # file older than 7 days print "This $file wil be deleted\n"; } } closedir DIR; }
In reply to Delete old files by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |