in reply to mashing two arrays
my %h = (); $h{$_->[0]} = [$->[1]] for @a1; # this will make empty arrayrefs automatically where necessary $h{$_->[0]}[1] = $_->[1] for @a2; my @b = map {[ $_ => @{$h{$_}} ]} sort keys %h;
(sort is probably ok to preserve the order here, but if it weren't, then Tie::IxHash might be helpful instead.)
-Paul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: mashing two arrays
by punkish (Priest) on Jan 19, 2007 at 17:51 UTC | |
by ikegami (Patriarch) on Jan 19, 2007 at 18:06 UTC |