in reply to directories

It should work on both. What exactly is going wrong?

You can test a filehandle or a filename with the -d file test operator, which returns true if the file is a directory, false if not, and undefined if the file was not found:
for $x ("windows", "sheep", "etc") { if (-d $x) { print "Found directory: $x\n"; } }