my $string = '15+2=17'; my $input = '5+2'; $string =~ m|$input|o; # Fails $string =~ m|\Q$input|o; # Succeeds