lock_value#

Make the value under a given key immutable.

Synopsis#

lock_value(%hash, $key);

Any subsequent attempt to overwrite $hash{$key} croaks with Modification of a read-only value attempted. The key itself remains deletable unless lock_keys has also been applied - once the key is deleted, a later assignment creates a fresh (writable) value. A key not already present is created with a read-only undef value, or croaks if a locked keyset does not allow it. On a hash whose keyset is not locked, lock_value warns Cannot usefully lock values in an unlocked hash when warnings are enabled.

Returns a reference to the hash.