How do I distinguish a file from a directory in Perl?
问题 I'm trying to traverse through all the subdirectories of the current directory in Perl, and get data from those files. I'm using grep to get a list of all files and folders in the given directory, but I don't know which of the values returned is a folder name and which is a file with no file extention. How can I tell the difference? 回答1: You can use a -d file test operator to check if something is a directory. Here's some of the commonly useful file test operators -e File exists. -z File has