sub extract (&\@) { my ($code, $aref) = @_; my @return; my @replace; for (@$aref) { # aliases $_ to the item in the original list if (&$code) { push @return, $_; } else { push @replace, $_; } } @$aref = @replace; return @return; }