use File::Find; find(\&wanted, $dir); sub wanted { unlink $_ if -M $_ > $days; }