BUG: folders can contain things other than files and folders.
I'm pretty sure this is true even in Windows.
eg when I do
dir C:\Users, I see
<DIR>s, but also
<SYMLINKD>s and
<JUNCTION>s (Windows Vista)
See
file test ops
So you might want to change lines 16-27 in your OP, as indicated by ##### in the following:
for my $file (@files)
{
print $file;
if(-f $file)
{
print " is a file.\n";
}
#else #####
elsif (-d _) #####
{
print " is a dir.\n";
}
else #####
{ #####
print " is something else.\n"; #####
} #####
}