my @blacklist = ('evil', 'bad', 'wrong'); my $a = "this string contains no blacklisted tokens"; my $b = "this string is evil and wrong"; my $regex = join '|', @blacklist; # The !~ is a better way to do !(foo =~ /regex/) if ($a !~ /$regex/) { print "Success with a!\n"; } else { print "Failure with a\n"; } if ($b !~ /$regex/) { print "Success with b!\n"; } else { print "Failure with b\n"; } #### my $regex = '.(?!evil)'; if ("this is so evil" =~ /($regex)/) { print "yay: $1\n"; }