Make N copies of [ @array ]( [ @array ] ) x @array ;
Do the hash assign of the N copies. This is all obvious so far, now for the trickier bit, the output@array{ @array } = ( [ @array ] ) x @array ;
Unusual, you say, that the key 'c' should get 'the original' and the rest get copies, but if we look at the ordering of the keys this makes sense%array = ( 'c' => [ 'a', 'b', 'c', 'd' ], 'a' => $array{'c'}, 'b' => $array{'c'}, 'd' => $array{'c'} );
So as you may have guessed by now Data::Dumper's output shows that 'c' just happens to look like its got 'the original' due to the ordering of the hash. In reality they all point to the same anonymous array.shell> perl -le 'print keys %{{map {$_=>1} qw/a b c d/}}' cabd
_________
broquaint
In reply to Re: Re: Getting different anonymous arrays
by broquaint
in thread Getting different anonymous arrays
by InfiniteSilence
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |