Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Why are Hash keys different for the same hash? Confusing.

by dsheroh (Monsignor)
on Feb 28, 2016 at 09:03 UTC ( [id://1156359]=note: print w/replies, xml ) Need Help??


in reply to Re: Why are Hash keys different for the same hash? Confusing.
in thread Why are Hash keys different for the same hash? Confusing.

The problem is with exists creating intermediate levels
Note that, if you consider this to be a problem you can install the autovivification module, then specify no autovivification to prevent it:
#!/usr/bin/env perl use strict; use warnings; use 5.010; no autovivification; use Data::Dumper; my %hash = ( a=>{} ); if ( !exists $hash{'a'}{'b'}{'c'} ){}; print Dumper \%hash;
Output:
$VAR1 = { 'a' => {} };
This is, however, apparently not an option for the OP, due to short-sighted customer requirements and autovivification is an XS module, so using its code independently of the original module would be a bit more involved than just copy/pasting the source.

Replies are listed 'Best First'.
Re^3: Why are Hash keys different for the same hash? Confusing.
by Anonymous Monk on Feb 28, 2016 at 10:20 UTC
      Oooh... Nice! That actually solves something that's come up in one of my work projects recently. Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found