my $match = join "|", map {quotemeta($_)} keys %replace; $str = s/<--($match)-->/$replace{$1}/g;