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?
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
See perlfunc manual page for more
Also, try using File::Find which can recurse directories for you. Here's a sample which looks for directories....
It would be easier to use
File::Find
.Look at the -X operators:
For directory traversal, use File::Find, or, if you're not a masochist, use my File::Next module which makes an iterator for you and doesn't require crazy callbacks. In fact, you can have File::Next ONLY return files, and ignore directories.
It's at http://metacpan.org/pod/File::Next