Logo

Programming-Idioms

History of Idiom 163 > diff from v16 to v17

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

Version 16

2019-09-27, 04:00:54

Version 17

2019-09-27, 21:44:33

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