# get the base file names my @files = readdir(DIR); # for each $file in @files, append the path to the front @files = map { $mydir."/".$_; } @files; # for each $file in @files, if it doesn't match the criteria then remove it from @files @files = grep { !/.+$/ && -M $_ > 1; } @files;