my @blacklist = ('evil', 'bad', 'wrong'); my $a = "this string contains no blacklisted tokens"; my $b = "this string is evil and wrong"; # The regex should express the blacklist is such a way that # it will match on any string which DOES NOT contain any of # the tokens in the blacklist, and it will fail to match on # any string which DOES contain tokens from the blacklist. my $regex = '?????'; if (($a =~ m/$regex/) && !($b =~ m/$regex/)) { # SUCCESS }