Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Undesirable parent hash keys

by davido (Archbishop)
on Jan 11, 2013 at 07:58 UTC ( #1012820=note: print w/ replies, xml ) Need Help??

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.


Comment on Re: Undesirable parent hash keys
Download Code
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 :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012820]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2015-11-25 03:42 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (670 votes), past polls