Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I could swear I've seen this behavior before, but can't find the post.
This returns something like: (before): $VAR1 = { 1 => { 'foo' => 'bar' }, 2 => { 'foo' => 'bar' }, 3 => { 'foo' => 'bar' } }; (after): $VAR1 = { 1 => { 'foo' => 'bar' }, 2 => { 'foo' => 'bar' }, 3 => { 'foo' => 'bar' }, 4 => {} };And I'm not sure why, my question is twofold: 1) Is there a good reason why perl creates the reference (4)? 2) Is there a good reason why perl doesn't WARN that I am trying to access a value that doesn't exist? Note that even taking out the || "djkafdkljfa" does not produce a warning The problem is appearing in a bit of code I am developing, and I can get around it, but this tripped me up while I was working on it (using exists($hashref->{key} to determine execution path). ps: Damn, I miss this place, I think it's time to start hanging out here again (especially now that I "do" perl for a living :)) In reply to Looping through a hash reference is creating a key...? by the_slycer
|
|