foreach (@chars) { if ($string =~ /$_/) { $anymatches++ } } if ($anymatches) { print "OK" } else { print "Oops" }