opendir(DIR, $dir); my (@filenames) = grep(!/^\.\.?$/, readdir(DIR)); closedir(DIR); for (@filenames) { ... something ... }