in reply to Re: special characters in regexp
in thread special characters in regexp

First, $a and $b are probably just dummy variables to indicate the problem. And even if they do, most of the time, there's no problem at all when using $a and $b.

But if we're nitpicking, if you shouldn't use a construct just because in some cases, this fails, you made a bigger boo-boo than the op with his $a and $b. You're trying to use $@ as an indication whether an eval failed or not. That's wrong; an eval may fail while $@ is false due to cleanup actions. The only way to be sure an eval succeeded is to check its return value:

eval { $matched = $contender =~ /$regexPattern/; 1; } or warn $@ // "Unknown error";