in reply to Deleting a Directory

If you changed
rmdir ( "$_" ) or die ("Could not remove $_");
to
rmdir ( "$_" ) or die "Could not remove $_ $!";
Then a more meaningful message would appear, which may well help you solve your issue.