http://www.perlmonks.org?node_id=506629


in reply to get directory listing

Use -d to determine whether it is a directory. By the way, don't chop(), but chomp() if it is needed. The following code was tested on Windows XP, don't have UNIX access handy:

opendir(DIRHANDLE,"c:/") || die "file to open"; for my $file (readdir DIRHANDLE) { print "$file\n" if (-d "c:/$file"); } closedir(DIRHANDLE);