in reply to Re: searching through array for multiple patterns
in thread searching through array for multiple patterns
of course in this case you can omit the $found ? print ...: print ..; part:#use a flag to indicate a match my $found = 0; foreach (@commands_run) { if($_ =~m/clock/) { $found++; last; # we have a match, exit loop } } $found ? print "\n Test -- found pattern -- \n" : print "\n Test -- did not find pattern -- \n";
foreach (@commands_run) { if($_ =~m/clock/) { print "found pattern\n"; last; # we have a match, exit loop } }
|
|---|