http://qs321.pair.com?node_id=11113733


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 (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