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


in reply to copy files and directories recursively

You have to adjust your logic.

You are not testing the entries to copy for being directories.

You have one -d test, but that is done on the "constant" (i.e. never changed) $newDir.