in reply to Finding the first element that passes a test - then saving the rest.

As long as the test depends only on the individual element, you can use the flip-flop operator "..".
@ans = grep { ($_ > 0) .. 0 } @array; $found = shift @ans;
  • Comment on Re: Finding the first element that passes a test - then saving the rest.
  • Download Code