Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Undesirable parent hash keys

by Athanasius (Monsignor)
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 browsing the Monastery: (5)
As of 2014-09-23 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (217 votes), past polls