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

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'd like to use a regex to filter out everything except a fixed string, say "accept everything except 'FOO'". I can easily do this with $str !~ /^FOO$/. But my problem is that I can't use !~, I have to use =~ because I'm passing the pattern to some other code. How do I do that?, I tried $str =~ /^^FOO$/ or /^^F^O^O$/, they certain don't do the right thing. Thanks