http://www.perlmonks.org?node_id=369322


in reply to Can't match negated words.

If you just want to match a line where a particular word doesn't appear in, !~ does the trick. But if "not this word" is part of a regular expression, the !~ will not do it. Instead, you basically have to "progress carefully", looking ahead on each step on your way. That is, match a character (any character) after you've concluded it doesn't start a forbidden word. If no character in the (sub)string you match doesn't start a forbidden word, no forbidden words will be in the matched string. How do you check? Use negative lookahead:
/^(?:(?!throw).)*$/s

Abigail