in reply to Using Splice with Two Arrays within a loop
I don't quite understand why you need a different approach to the same goal in your second snippet. I do think it's clever to have passed a count value for the first array as a way of dealing with the fact that Perl flattens lists, but references are built into the language, in part, to deal with that problem more conveniently. Passing a count is so... "C". ;)
However, if I were doing it, I would just use List::MoreUtils "zip" function (also known as mesh):
use List::MoreUtils qw( zip ); my @first = qw( can unlock secret ); my @second = qw( you the code? ); my @mixed = zip @first, @second; print "@mixed\n";
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Splice with Two Arrays within a loop
by Anonymous Monk on Jun 10, 2013 at 17:34 UTC |