Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Pathologically Eclectic Rubbish Lister
 
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
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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-04-23 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (557 votes), past polls