in reply to replace part of directory

I think you're taking the wrong approach. You might try something like:

use File::Find; my $oldroot = shift; my $newroot = shift; find(\&wanted, $oldroot); sub wanted { # Chop off $oldroot prefix, glom on $newroot prefix print $newroot, substr($File::Find::name,length($oldroot), "\n"; }

Note: Untested code, you'll likely need to fix it.

...roboticus