in reply to Combining two references

De-reference them as arrays inside an array reference, and assign that to a variable:

my $all = [ @$data1, @$data2 ]; print Dumper $all;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Combining two references
by Anonymous Monk on Jun 08, 2015 at 17:42 UTC
    Trying this way and getting this error:

    Not a HASH reference at...
    my $all = [ $data1, $data2 ]; foreach my $row ( @{ $all } ) { my $name = $row->{ NAME }; my $car1 = $row->{ CAR1 }; warn Dumper $name; warn Dumper $car1; }

      It fails because you kept the same buggy code instead of using jeffa's fix.

      Again, the fix is to deference the arrays to get their elements: @$data1, @$data2

      That will not work. Since you have a single hash within each array element (and the hashes have colliding key names), you have to extract each hash, and pull the NAME (CAR1 will fail as this hash doesn't have this key). However, the next iteration will overwrite NAME, and still fail on CAR1. On the following two iterations over the array, the exact opposite will happen.

      You will have 'Undefined variable' warnings everywhere.

      Why don't you state what it is that you want to do with the data in the end, and perhaps we can guide you to a data structure that fits your needs?

      -stevieb