2 ms·
I think if prodigal_erik is worried about autovivification then perhaps locking the keys might be a good idea?... use 5.016; use warnings; use Hash::Util
by draegtun 13y ago
I think if prodigal_erik is worried about autovivification then perhaps locking the keys might be a good idea?...
use 5.016;
use warnings;
use Hash::Util 'lock_keys';
my %a = (B => 100); # B but no A defined
lock_keys %a;
my $x = 'A';
++$a{$x};
Above now throws an error on the last line - Attempt to access disallowed key 'A' in a restricted hash...
Alternatively autovivification can be switched off - https://metacpan.org/pod/autovivification https://metacpan.org/pod/autovivification