A sometimes easily overlooked reason why setting permissions fail is because the effective UID of the perl script is different to the currenly logged on user, so where you might be able to edit a key via regedit, RegSetKeySecurity might be failing due to insufficient permissions. See
Have you also tried using the Win32API::Registry implementation of RegSetKeySecurity?