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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: merging anonymous arrays
by choroba (Cardinal) on Nov 16, 2012 at 08:37 UTC | |
by johngg (Canon) on Nov 16, 2012 at 13:29 UTC | |
by ColonelPanic (Friar) on Nov 16, 2012 at 14:24 UTC | |
by ColonelPanic (Friar) on Nov 16, 2012 at 10:33 UTC | |
|
Re^2: merging anonymous arrays
by SavannahLion (Pilgrim) on Nov 16, 2012 at 08:36 UTC |