My current script will take an expression, ex:
my $expression = \'( a || b || c )\';
and go through each boolean combination of inputs using su
You use the pattern a*
thinking it will match only a*
, but a*
means "0 or more a
". You can use quotemeta
to convert text into a regex pattern that matches that text.
Replace
my $keys = join '|', keys %stimhash;
with
my $keys = join '|', map quotemeta, keys %stimhash;
\b
is basically
(?
But *
(like the space) isn't a word character. The solution might be to replace
s/($keys)\b/$stimhash{$1}/g
with
s/($keys)(?![\w*])/$stimhash{$1}/g
though the following make more sense to me
s/(?
Personally, I'd use
s{([\w*]+)}{ $stimhash{$1} // $1 }eg