in reply to Pattern matching with a variable

I think you are looking for quotemeta or \Q and \E. See perlre.

May the Force be with you