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


in reply to Maybe Escape in Dynamic RegExps

The simplest way would be to use the \Q and \E in the expression:

$re= qr(/($<!\Q$a\E)\Q$b/);
and it will do the right thing.

/J\