The !~ operator negates the return value of the =~ operator,
not of the regular expression. In an s/// operation, the
result of $string will be the same regardless of whether
!~ or =~ is used, as all that is being negated is the number
of matches returned. What you're looking for is