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

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

I want to use pattern-matching operators with the pattern stored in a variable, e.g. m/$pattern/, s/$pattern/$replacement/. The problem is that the patterns may include characters (like brackets) which are special in regular expressions, thus causing an undesired result. What would be the best way to handle this problem?

Originally posted as a Categorized Question.