Which of course produces the same result just as you explain. But after messing with this I am not able to make it do what I want.use strict; use warnings; use Data::Dumper; my $data1 = [ { "shape" => "round", "food" => "apple" }, { "shape" => "square", "food" => "pear" } ]; my $data2 = [ { "big" => "cow", "small" => "bunny" }, ]; my $combined; foreach my $r (@{$data1}) { $r->{sizes} = $data2; push(@{$combined},$r); } print Dumper($combined);
I suppose it is because I am not really grasping it totally, which bothers me because I thought I had references down.
Can you modify the code above to produce the result I am looking for... do you see what I am trying to do? $data2 needs to reside outside that loop and I am wanting this result:
Thanks! Thanks!$VAR1 = [ { 'food' => 'apple', 'shape' => 'round', 'sizes' => [ { 'small' => 'bunny', 'big' => 'cow' } ] }, { 'food' => 'pear', 'shape' => 'square', 'sizes' => [ { 'small' => 'bunny', 'big' => 'cow' } ] } ];
In reply to Re^2: Strange hash array behavior
by Rodster001
in thread Strange hash array behavior
by Rodster001
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |