$_ = 'Hello World'; my %h = ( e => 'b', l => 'd', ); my $k = join '', keys %h; # Sure, I mean '' Thx@bazar s/([$k])/$h{$1} || $1/eg; print