Examplemy @odd = grep {state $i=1; $i++ % 2} qw{a 1 b 2 c 3}; my @even = grep {state $i=0; $i++ % 2} qw{a 1 b 2 c 3};
perl -e 'use v5.10; my @odd = grep {state $i=1; $i++ % 2} qw{a 1 b 2 +c 3}; say @odd;'
In reply to Re^2: alternate array elements
by mrdvt92
in thread alternate array elements
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |