Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Answer: How to prevent metacharacter interpolation

by jmcnamara (Monsignor)
on Mar 14, 2001 at 15:36 UTC ( #64364=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How to prevent metacharacter interpolation - Answer contributed by jmcnamara

Use either the quotemeta function:
$pattern = quotemeta( $pattern ); m/$pattern/;
or use the \Q and \E escape characters:
m/\Q$pattern\E/;
They do exactly the same thing; just one is a function and the other works inside regex patterns.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2016-12-06 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (120 votes). Check out past polls.