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

broquaint: this appears to fail for an array such as ( -1, -2, 10, -3, 2 ), because on the first iteration (when $_ == 0 ), $_ - 1 is the last element of the array:

my @ary = qw ( a b c 2); print $ary[-1];

Please correct (and downvote accordingly :-) if I've missed something

dave

  • Comment on Re: Re: Finding the first element that passes a test - then saving the rest.
  • Download Code