Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by talexb (Canon)
on Mar 03, 2020 at 19:05 UTC ( #11113728=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?

Uh .. no.

tab@music4:~ $ perl -de 1 Loading DB routines from perl5db.pl version 1.51 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 1 DB<1> %hash = (); DB<2> use Data::Dumper; DB<3> print Dumper(\%hash) $VAR1 = {}; DB<4> if ( exists $hash{nothing} ) { print "Wow.\n"; } DB<5> !3 print Dumper(\%hash) $VAR1 = {}; DB<6>
For me, the whole point of using exists is to avoid doing autovivification.

But the example used a two level hash .. so I answered the wrong question. Ugh.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Replies are listed 'Best First'.
Re^3: How Do I End Up With a Larger Number of Hash Keys Here?
by pryrt (Monsignor) on Mar 03, 2020 at 19:40 UTC
    Uh .. no.

    Actually, yes. 1nickt had a HoH, not just a simple hash. Intervening levels can and do get created, even when called by exists

    > perl -de 1 Loading DB routines from perl5db.pl version 1.27 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> %hoh = (); DB<2> use Data::Dumper; DB<3> print Dumper(\%hoh) $VAR1 = {}; DB<4> if (exists($hoh{nothing}{second})) { print "wow.\n"; } DB<5> !3 print Dumper(\%hoh) $VAR1 = { 'nothing' => {} };

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2021-09-25 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?