Every other

Andy Wardley abw at wardley.org
Fri Oct 30 16:05:52 GMT 2009


On 30/10/2009 09:05, Mark Fowler wrote:
> Ideally this would be a utility in List::MoreUtils or suchlike, but
> it's not.

C<part> will do what you want.

   use List::MoreUtils 'part'
   my $i = 0;
   my @part = part { $i++ % 2 } 1 .. 8;

   # @part now contains reference to 2 lists, the odd and even elements

It's not very clean, though, or particularly efficient.

A




More information about the london.pm mailing list