http://qs321.pair.com?node_id=11119307

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I need to merge this data into one dataset, I tried this:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; # This is the dump of a sample data and added to $var1 $var2 $var3 my $var1 = [ { 'date' => '2001-06-04', 'number' => '12345', 'amount' => '100.00', 'status' => 'paid', 'type' => 'new' }, { 'date' => '2000-001-02', 'number' => 'xc234', 'amount' => '30.88', 'status' => 'new', 'type' => 'cost' } ]; my $var2 = [ { 'ppay' => 'Smith Doe' } ]; my $var3 = [ { 'deb1' => '0', 'cred' => '0', 'addr' => '100 - Main Street', 'total' => '250.00 usd', }, { 'deb1' => '0', 'cred' => '50.14', 'addr' => '1 - Central', 'total' => '51.00', } ]; my ($data) = {$var1, $var2, $var3}; print Dumper $data;

Result:

Odd number of elements in anonymous hash at merge.pl line 53.
$VAR1 = { 'ARRAY(0x14bd858)' => [ { 'ppay' => 'Smith Doe' } ], 'ARRAY(0x14cb430)' => undef };


I am looking for this data dump:

$VAR! = [ { 'date' => '2001-06-04', 'number' => '12345', 'amount' => '100.00', 'status' => 'paid', 'type' => 'new' }, { 'date' => '2000-001-02', 'number' => 'xc234', 'amount' => '30.88', 'status' => 'new', 'type' => 'cost' }, { 'ppay' => 'Smith Doe' }, { 'deb1' => '0', 'cred' => '0', 'addr' => '100 - Main Street', 'total' => '250.00 usd', }, { 'deb1' => '0', 'cred' => '50.14', 'addr' => '1 - Central', 'total' => '51.00', } ];

Thanks for the help!