in reply to Re: how to print two array with new line at end of each second array element, using a single print statement?
in thread how to print two array with new line at end of each second array element, using a single print statement?
I was just about to follow up with that pairwise option. Glad I saw your update before I did. But I still wanted to mention that I find it necessary to write it something like this:
print pairwise{ no warnings 'once'; "$a $b\n" } @nums, @dat;
...lest I get a pair of warnings that $a and $b are used only once.
List::MoreUtils provides several ways to do it. This isn't quite as elegant, but still seemed neat to me.
my $ea = each_array( @nums, @dat ); while( my( $n, $d ) = $ea->() ) { print "$n $d\n"; }
Update: I've submitted a patch and a corresponding test targeting the 'used only once' warnings.
Dave
|
|---|