http://www.perlmonks.org?node_id=445956


in reply to The Bad, the Ugly, and the Good of autovivification

I'm finding misspelled keys enough of a problem in my applications that I'm considering drastic solutions like Tie::Hash::FixedKeys for critical hashes where I know the keys in advance.
use strict; use Tie::Hash::FixedKeys; my %a : FixedKeys( qw(a b) ); %a = (a => 1, b=> 2); print "Doesn't exist\n" unless exists($a{c}); print "Also Doesn't exist\n" unless exists($a{c}->{d}); print "Oh, my, not good\n" if exists($a{c});

The attempted autovivification on line 7 will cause a croak.