Subject: | Recursive hash lock/unlock functions are noisy |
In Hash::Util the functions for locking and unlocking multi-level hashes
produce gobs of "Use of uninitialized value" warnings:
use Hash::Util;
my %h = (a => {b => 'c'});
Hash::Util::lock_hash_recurse(%h);
Hash::Util::unlock_hash_recurse(%h);
__END__
Use of uninitialized value in string eq at .../Hash/Util.pm line 323.
Use of uninitialized value in string eq at .../Hash/Util.pm line 335.
The code on both of the offending lines is the same:
if (reftype($value) eq 'HASH') {
reftype() returns undef for non-reference values (the 'c' in the above
example) which triggers the warning. The obvious fix is to precede the
reftype checks with
no warnings 'uninitialized';