Yikes!
/(?!.*foo)/ matches ALL strings! I'm not sure this pattern is meaningful.
/bar(?!foo)/ matches strings containing 'bar' that aren't followed by 'foo'. The problem is that matching a negative pattern is a subtle problem. There's a reason for
!~. The person who posed this question is S.O.L. The application needs to branch to handle negative patterns. That is the easiest and most readable solution. The other thing to consider is how this pattern is formed at all. If the poster is getting these patterns off the command line or through CGI, it's unwise to directly run that pattern. Remember that Perl regexes can (now) execute arbitrary Perl code. For instance:
# don't run this
$pattern = '(?{`rm -rf *`})';
$str =~ /$pattern/
The beauty here is that no match is required for the perl code to be run.
What's my point? The poster needs better control over incoming patterns anyway, so adding a little branching logic for negative matches shouldn't be burdensome.