good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Putting an array into a hash gives an unexpected reference to the hash itself.by frozenwithjoy (Priest) |
on Nov 07, 2012 at 23:26 UTC ( [id://1002767]=note: print w/replies, xml ) | Need Help?? |
The problem is that you are creating two references to the same thing and want them to be distinct, but they aren't (because they reference the same thing...).
Instead of this:
You probably want this:
Below is an example showing what can happen when using/altering references. I make two references to a single scalar, alter one of the references and show that the contents of the original scalar and both references to that scalar change (but not a copy of the original).
Output:
In Section
Seekers of Perl Wisdom
|
|