in reply to Re: Mini-Tutorial: Working with Odd/Even Elements
in thread Mini-Tutorial: Working with Odd/Even Elements

$ perl -wE 'say grep {state $t ^= 1} qw[a b c d]' ac $

Replies are listed 'Best First'.
Re^3: Mini-Tutorial: Working with Odd/Even Elements
by salva (Canon) on Jul 09, 2009 at 19:14 UTC
    oops...
    $ perl -de 1 ... DB<1> use 5.010; sub a { grep { state $t ^= 1 } @_ } DB<2> x a(1..5) 0 1 1 3 2 5 DB<3> x a(1..5) 0 2 1 4
      That's a feature! You first get the odd elements, then the evens! ;-) ;-)