Alex Rivera | Logout

How do I distinguish a file from a directory in Perl?

Asked 2008-10-15T20:31:15.640
20

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?

Edit
Report

1 Answer

5
my @files = grep { -f } @all;
my @dirs = grep { -d } @all;
answered 2008-10-21T19:51:52.143

Your Answer