in reply to Changing a DN with Net::LDAP

Have you tried doing it without this bit:
(my $new = $dn) =~ ...
and just assigning $new its proper value? Also I'm not sure you need the ou= in there, as the values should be unique. With moddn you should not have to delete anything, it should alter the existing entry. Check that $entry contains what you think it should too..