$sentence =~ s{ ( $phrases ) }{ ( my $string = $1 ) =~ tr/ /_/; "%$string%" }xieg;