in reply to How to disable Pattern Matching ?
is indeed one way to use it properly.$text =~ /\Q$search/
Another, more primitive way to achieve the same effect is to precede every \W character with a backslash. That is actually exactly what quotemeta does.
$search =~ s/(\W)/\\$1/g; # same as: $search = quotemeta($search); $text =~ /$search/ # no "\Q" tis time!
|
|---|