opendir(DIR, "/tmp") || die "can't opendir $!"; while (my $file = readdir(DIR)) { next unless (-f "/tmp/$file"); print $file."\n"; } closedir DIR;