in reply to read only variable

Look into Hash::Util. Plenty of routines to choose from, lock_hash() is the most brutal one.