A '+' has a special meaning in a regular expression (it means "one or more of the preceding character"). Two of them in succession is a regex syntax error.
Your problem is that you have regex metacharacters that you want to be treated as normal characters. That is what the \Q escape sequence is for.
print "Found" if $string =~ /\Q$substr/;
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: Storing regexps in variables
by davorg
in thread Storing regexps in variables
by pando
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |