Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Undesirable parent hash keys

by Athanasius (Chancellor)
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,

Replies are listed 'Best First'.
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?
[erix]: yes, very handy that. I always use the one-page html version (dumped a local copy of it)
[erix]: (easier for searching)
choroba tries to grep -i choroba absg.html
[erix]: I count 3 (+1 in the list)-- wel done :)
[choroba]: I've read it body to /body and experimented a lot...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2017-11-24 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (348 votes). Check out past polls.

    Notices?