in reply to Renaming Directories Recursively

As others have mentioned, File::Find goes through all the entries of one directory, and then it goes to the subdirectory, which fails when the name changes. Fortunatly, File::Find has a workaround. You can either call find like:

find({ bydepth => 1, wanted => \&rem_space }, $dir);

or do this:

finddepth(\&rem_space, $dir);

These both cause File::Find to go through all the items inside a directory before handling the directory itself (as described in its documentation) so you can rename without messing it up.