http://qs321.pair.com?node_id=871771


in reply to Get even postion elements in an array

@output = grep $|--, @input;

using some magic of $| for the flipflop.

But unless you use it for a real oneliner, use some less obscure formulation of the principal shown in previous replies. ;-)

Replies are listed 'Best First'.
Re^2: Get even postion elements in an array
by Anonymous Monk on Oct 20, 2016 at 01:25 UTC
    $ perl -e 'my @a=(2, 3, 4, 5, 1, 7); print ("==> ", (map{$_ % 2 ? (): +" $a[$_]"} 0..$#a), "\n");' ==> 2 4 1