Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Perl: the Markov chain saw
 
PerlMonks  

Re: Undesirable parent hash keys

by Athanasius (Prior)
on Jan 11, 2013 at 07:50 UTC ( #1012817=note: print w/ replies, xml ) Need Help??


in reply to Undesirable parent hash keys

You should be testing using exists, because the boolean test you are using will return false if the hash element exists but is undef or zero or the empty string...

That said, I don’t think there is any way to do what you want without the clumsy cascade of tests:

if (exists $Hash{'2013'} && exists $Hash{'2013'}{'Oct'} && ...

because exists also autovivifies intervening elements. According to the documentation:

This surprising autovivification in what does not at first—or even second—glance appear to be an lvalue context may be fixed in a future release.

:-(

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re: Undesirable parent hash keys
Select or Download Code
Re^2: Undesirable parent hash keys
by sophate (Beadle) on Jan 11, 2013 at 07:55 UTC

    Noted and thanks for your prompt response.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012817]
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: (7)
As of 2014-04-17 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls