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

Oh no it doesn't !
mkdir test\ this perl -e 'opendir (DIR,"./");@files = readdir DIR;foreach $file (@files +){print "$file is a directory\n" if (-d $file);}' test this is a directory .. is a directory . is a directory
Could you provide a wider picture of the issue, perhaps an ls -lR of the directory structure and a larger code snippet?