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


in reply to Undesirable parent hash keys

See autovivification, a pragma (available from CPAN) that can lexically disable autovivification (the behavior). Here's an example from perlfaq4:

{ no autovivification; my %hash; if( exists $hash{key1}{key2}{key3} ) { ...; } }

The faq also suggests a few other techniques.


Dave

Replies are listed 'Best First'.
Re^2: Undesirable parent hash keys
by sophate (Beadle) on Jan 16, 2013 at 06:20 UTC

    thanks for the suggestion. but i'm planning to write my own function to check if a hash key exists without autovivification :-)