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


in reply to Re: Can't match negated words.
in thread Can't match negated words.

First, You haven't duplicated Abigail-II's expression correctly; if you do so, it will work correctly:

if ($line =~ /^(?:(?!throw).)*$/s) { debug ("Doesn't contain throw"); }

An alternative formulation, which I find slightly cleaner, is to recast it as a single negative lookahead:

if ($line =~ /^(?!.*?throw)/) { ... }

Hugo