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