... foreach $file (readdir DH){ my $path = "$dir_to_process/$file"; unlink $path or warn "failed on $path: $!\n" if -M $path > 14; }