This is an easy mistake to make. I've made it myself. Notice that in $bit, you have parentheses '()' and a plus '+'. What your regex is doing is trying to find one or more fours followed by one five. It then, if successful, would capture this to $1.
The easiest way to deal with the is to use the "quote" metacharacters (\Q and \E) in the regex.
$formula = $bit = '(4+5)';
if( $formula =~ /\Q$bit\E/ ) {
print "yeah\n";
} else {
print "Oh no!\n";
}
This will work as you expect. However, you'll have to be careful. Here's a warning from
perlop:
You cannot include a literal $ or @ within a \Q sequence. An unescaped $ or @ interpolates the corresponding variable, while escaping will cause the literal string \$ to be inserted. You'll need to write something like m/\Quser\E\@\Qhost/.