Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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.


Dave


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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2015-07-30 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls