in reply to deleting windows subdirectories

Try using File::Path
use File::Path; rmtree(['/foo/bar/baz', $directory2],0,1);
Putting a 1 as the second param will have rmtree print a msg about whether or not it is rmdir or unlinking a dir/file.