Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 ( #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.
  • Comment on Re^2: How Do I End Up With a Larger Number of Hash Keys Here?

Replies are listed 'Best First'.
Re^3: How Do I End Up With a Larger Number of Hash Keys Here?
by BillKSmith (Prior) 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
Node Status?
node history
Node Type: note [id://11113733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2020-05-27 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?