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 '@'. In reply to Re: How do I escape metacharacters in a user-defined string?
by Perlmage
in thread How do I escape metacharacters in a user-defined string?
by Coyo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |