in reply to Re: map function use
in thread map function use
... if you factor out the common \s.But if @phrases was something like qw(foo bar baz) then the final substitution regex would be equivalent tomy $string = join '|', map {quotemeta} @phrases; $sentence =~ s/(\s$string\s)/#$1#/g;
Adding a non-capturing sub-grouping should do the trick:
$sentence =~ s/(\s(?:$string)\s)/#$1#/g;
|
|---|