in reply to How do I escape metacharacters in a user-defined string?
You could also use quotemeta(), which is how the \Q is implemented. Ie.,
$formula = '(4+5)';
$bit = quotemeta $formula;
if ( $formula =~ /$bit/ ) {
print "yeah\n";
} else {
print "Oh no!\n";
}
This will handle literal '$' and '@'.
|
|---|