in reply to match with exception

The other answers are correct if all you want to do is not match an entire pattern. But sometimes you want an expression that matches in one part but does not match in another. To do this you need to use look around assertions. For example, if you want a pattern that matches "abc" if it is not followed by "xyz" you would do this:
my $s = "abcxyQ"; if ($s =~ /abc(?!xyz)/) { print "Matches '$s'\n"; } else { print "Doesn't Match '$s'\n"; } my $t = "abcxyz"; if ($t =~ /abc(?!xyz)/) { print "Matches '$t'\n"; } else { print "Doesn't Match '$t'\n"; }
The look-ahead assertion is inside the (?!). Read the perl documentation about this feature - it is tricky and does not always work as expected (but it does work as designed!)

- Paul