Array-Extract

 view release on metacpan or  search on metacpan

lib/Array/Extract.pm  view on Meta::CPAN

  my @numbers = (1..100);
  my @odds = extract { $_ % 2 } @numbers;

Care is taken to do the least number of splice
operations as possible (which can be important when
the array is a tied object with a class such as
Tie::File)

=cut

sub extract(&\@) {
  my $block = shift;
  my $array = shift;

  # loop invariants.  The element we're currently on
  # and the length of the array
  my $i = 0;
  my $length = @{ $array };

  # the index we started removing from
  my $remove_from;



( run in 1.694 second using v1.01-cache-2.11-cpan-49f99fa48dc )