in reply to map function use

Perhaps you want something like this:

my $string = '(?<=\s)(' . join( '|', map "\Q$_", @phrases ) . ')(?=\s) +'; $sentence =~ s/$string/#$1#/g;