bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Perl uses a little magic to combine arrays, but the more complex reference to an AoH requires a bit more magic
ARRAYS:
my @aoh1 = qw (value1 value2); my @aoh2 = qw (value3 value4); @aoh2 = (@aoh1, @aoh2);
output:
@aoh2 = ('value1', 'value2', 'value3', 'value4' );
AoH's:
@aoh1 = ({ 'key1' => 'value1', 'key2' => 'value2' }); @aoh2 = ({ 'key3' => 'value3', 'key4' => 'value4' }); @aoh2 = (@aoh1, @aoh2);
output:
@aoh2 = ( { 'key2' => 'value2', 'key1' => 'value1' }, { 'key4' => 'value4', 'key3' => 'value3' } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I combine arrays and array of hashes?
by fullermd (Vicar) on Dec 31, 2008 at 06:46 UTC | |
by eye (Chaplain) on Jan 01, 2009 at 11:28 UTC |