in reply to Re: Combining two references
in thread Combining two references

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; }

Replies are listed 'Best First'.
Re^3: Combining two references
by ikegami (Patriarch) on Jun 08, 2015 at 17:48 UTC

    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

Re^3: Combining two references
by stevieb (Canon) on Jun 08, 2015 at 17:50 UTC

    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