http://www.perlmonks.org?node_id=1004149


in reply to merging anonymous arrays

Your existing code is but one layer of indirection away from wielding anonymous arrays:

my $a_ref = [ qw/ A B C D E F G H / ]; my $b_ref = [ qw/ 7 6 5 4 3 2 1 0 / ]; my @KEY = map { $a_ref->[$_], $b_ref->[$_] } 0 .. $#{$a_ref};

Similar functionality also exists in List::MoreUtils with the "zip" and "mesh" functions (they're synonymous).

use List::MoreUtils qw( zip ); my $a_ref = [ qw/ A B C D E F G H / ]; my $b_ref = [ qw/ 7 6 5 4 3 2 1 0 / ]; my @KEY = zip @{$a_ref}, @{$b_ref};

Dave