You need \Q...\E which quotes metacharacters in regexes.
if ($a =~ m/\Q$b\E/)
See also quotemeta
By the way, $a and $b have a special meaning to Perl (because of their use in sorting) so it's a really bad idea to use them for anything else.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Regular expression match trouble with "+"
by davorg
in thread Regular expression match trouble with "+"
by kwyjibo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |