#!/usr/bin/perl -l use strict; use warnings; my @blacklist = ('evil', 'bad', 'wrong'); #$a and $b are bad variable names due to sorting things my $aa = "this string contains no blacklisted tokens"; my $bb = "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 = qr/^(?!.*(?:evil|bad|wrong))/; if (($aa =~ m/$regex/) && !($bb =~ m/$regex/)) { print "Woohoo"; }