in reply to Re^2: searching through array for multiple patterns
in thread searching through array for multiple patterns

I'm with you, in that case just set a flag if the element is found, then break out of the loop at once (no point in continuing to search):
my $found = 0; foreach (@commands_run){ if($_ =~ m/clock/) { $found = 1; last; } } if ($found) { print "\n Test -- found pattern -- \n" } else { print "\n Test -- did not find pattern -- \n" }