my $re = join '|', map quotemeta, keys %dict; s/($re)/$hash{$1}/g;