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

this should do what you want. also, it will work if a zero value is found in the data, which fails with your current test. i've included some test data and examples.

#!/usr/bin/perl use strict; use warnings; $|++; sub to_zero_or_below { ## must have a two element list to process return unless 2 <= @_; for my $index ( 1..$#_ ) { ## skip unless i've decended to zero or below next unless $_[$index - 1] > 0 and $_[$index] <= 0; ## return the remainder of the list return @_[$index..$#_]; } } my @data= ( -3, -1, 1, 3, 2, 1, 0, -1, -2 ); ## zero present print $_, $/ for to_zero_or_below( @data ); print "~~~\n"; ## no zero print $_, $/ for to_zero_or_below( reverse @data );

~Particle *accelerates*