How to improve the usage of lock_keys in Perl?
问题 I'm using Hash::Util 's lock_keys to die whenever trying to access a non-existing key in a hash. Sometimes my hashes are deep (hash of hashes of hashes...). Is there a quick method to lock them all at once? Is it possible to control the default message upon failure (i.e. add a Dump of the hash in which the key wasn't found) 回答1: lock_hash_recurse Catch the exception, then dump as you wish and rethrow. use Try::Tiny; try { $hash{key} = 123; # illegal modification } catch { use DDS; DumpLex \