in reply to Merging arrays
TIMTOWTDI¹...
...your AoH w/o extra modules and complicated maps using a temporary hash-slice:
DB<100> @array = qw( 111 222 333 444 555 888 ); => (111, 222, 333, 444, 555, 888) DB<101> @array2 = qw( acct1 acct2 acct3 acct4 acct5 acct8 ); => ("acct1", "acct2", "acct3", "acct4", "acct5", "acct8") DB<102> @temp{@array}=@array2 => ("acct1", "acct2", "acct3", "acct4", "acct5", "acct8") DB<103> @AoH = map { { $_ => $temp{$_} } } @array => ( { 111 => "acct1" }, { 222 => "acct2" }, { 333 => "acct3" }, { 444 => "acct4" }, { 555 => "acct5" }, { 888 => "acct8" }, )
(ignoring your typo)
¹) Note elements of @array must be unique ...
Cheers Rolf
( addicted to the Perl Programming Language)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Merging arrays
by AnomalousMonk (Archbishop) on Jun 28, 2013 at 02:19 UTC | |
by LanX (Saint) on Jun 28, 2013 at 13:50 UTC | |
by AnomalousMonk (Archbishop) on Jun 28, 2013 at 19:26 UTC |
In Section
Seekers of Perl Wisdom