in reply to Re: alternate array elements
in thread alternate array elements
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;'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: alternate array elements
by LanX (Saint) on May 12, 2023 at 21:19 UTC |