opendir (DIR, $dir) or die "cannot opendir $dir"; foreach my $file (readdir(DIR)) { &process_file ($file); } closedir (DIR); #### my @only_files = grep {-f "$dir/$_"} readdir(DIR); foreach my $file (@only_files) { &process_file ($file); } #### map {&process_file} grep {-f "$dir/$_"} readdir(DIR);