#### Need to keep this code unchanged opendir DIR, "Whatever/path"; @files=grep { !/^\.+$/ } readdir(DIR); closedir DIR; ####Need to return only files in code shown below. I have tried -f $file, !-d $file, -e$file in my if condition and it is still returning Files and directories. foreach $file (@files) { if (-f $file) { #print whatever } }