Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How Do I End Up With a Larger Number of Hash Keys Here?

by perldigious (Priest)
on Mar 03, 2020 at 19:41 UTC ( [id://11113733]=note: print w/replies, xml ) Need Help??


in reply to Re: How Do I End Up With a Larger Number of Hash Keys Here?
in thread RESOLVED - Autovivification: How Did I End Up With a Larger Number of Hash Keys Here?

Helps a lot, that's the problem I'm having.

https://perlmaven.com/autovivification

Also, good God, why?

I'd be more inclined to call that a bug than a feature, especially in the exists/delete context I'm doing above.

I'm both amazed I haven't run in to this prior, and terrified that maybe I have in past code I've written and I just never realized it. :-o

Just another Perl hooker - My clients appreciate that I keep my code clean but my comments dirty.

Replies are listed 'Best First'.
Re^3: How Do I End Up With a Larger Number of Hash Keys Here?
by BillKSmith (Monsignor) on Mar 06, 2020 at 16:29 UTC
    Its probably to late, but I do want to point out that your original code would work as intended (and perhaps even be clearer) if you test the levels separately. The "short circuit" feature of the "and" operator prevents the troublesome low-level test from running unless the upper-level key exists.
    if ( exists $auto_picks{ $data[0] } and exists $auto_picks{ $data[0] }{ $data[1] } ) {
    Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-28 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found