in reply to Combining two references

Hello Anonymous,

Although that the other monks have already answered your question I would like to add something. Why not to use ARRAYS OF HASHES?

Sample of code provided under:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @data1 = ( { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', }, { 'NAME' => 'ANTHONY RD', 'DATE' => '2012-01-07', 'NUMBER' => '00003', } ); print Dumper \@data1; =data1 $VAR1 = [ { 'NUMBER' => '00001', 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05' }, { 'DATE' => '2012-01-07', 'NUMBER' => '00003', 'NAME' => 'ANTHONY RD' } ]; =cut my @data2 = ( { 'CAR1' => '1', 'CAR2' => '2', 'CAR3' => '3', }, { 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b', } ); print Dumper \@data2; =data2 $VAR1 = [ { 'CAR3' => '3', 'CAR1' => '1', 'CAR2' => '2' }, { 'CAR3' => '3b', 'CAR1' => '1b', 'CAR2' => '2b' } ]; =cut push my @AoH , ( @data1 , @data2 ); =alternatively my @AoH = ( @data1 , @data2 ); =cut print Dumper \@AoH; __END__ $VAR1 = [ { 'NUMBER' => '00001', 'DATE' => '2009-05-05', 'NAME' => 'PAUL DY' }, { 'NUMBER' => '00003', 'NAME' => 'ANTHONY RD', 'DATE' => '2012-01-07' }, { 'CAR3' => '3', 'CAR2' => '2', 'CAR1' => '1' }, { 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b' } ];

There are many ways to play around with these just try.

For example you can Making References with array of hashes.

Sample of code:

my $refAoH = \@AoH; print Dumper $refAoH;

Same result as above.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: Combining two references
by Anonymous Monk on Jun 09, 2015 at 13:25 UTC
    Whats in your option should be the most efficient way to interact (loop) over this ARRAYS OF HASHES?

    Thanks!