foreach (@array) { next unless $_ eq $test; #here is a match # ... last; }