Every other

Philip Potter philip.g.potter at gmail.com
Fri Oct 30 11:13:24 GMT 2009


2009/10/30 Mark Fowler <mark at twoshortplanks.com>:
> my $i;
> my @new = grep { $i = !$i } @old;

Thinking about it further, this could be more readable as:

my @new = grep { ++$i % 2 } @old;

[idea stolen from pod for List::MoreUtils::part]

Phil


More information about the london.pm mailing list