use strict; use Hash::Util qw(lock_keys); my $hash = { uhu1 => 1 }; lock_keys(%$hash); $hash->{uhu2} = 0; ^Z Attempt to access disallowed key 'uhu2' in a restricted hash at - line 6.