in reply to mashing two arrays
An alternative to jettero's solution is
which is very easy to generalize to more than two arrays. The idea ismy %baz; $baz{$_->[0]}{foo} = $_->[1] for @foo; $baz{$_->[0]}{bar} = $_->[1] for @bar; my @baz; for my $k (sort keys %baz) { push @baz, [ $k, @{$baz{$k}}{qw(foo bar)} ]; } use Data::Dump 'dump'; print dump(\@baz);
|
|---|