Programming-Idioms

History of Idiom 163 > diff from v16 to v17

Edit summary for version 17 :
New Perl implementation by user [daxim]

Version 16

Version 17

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Imports
use List::Util qw(pairs);
Code
foreach (pairs @list) {
   print "@$_\n";
}
Doc URL
http://p3rl.org/List::Util#pairs