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


in reply to if (-d$_) failes because of white space

Try wrapping quotes around $_.

my $dir = "\'$_\'";

Some OS platforms don't like those spaces (even tho it allows you to put them into the directory names *cough*windows*cough* :-)