in reply to Re: simple letter substitution according to hash
in thread simple letter substitution according to hash

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

I think you want either ($k) or my $k = join '', keys %h; in the latter case one would probably also want to check that the keys are actually single letters. In both cases || $1 wouldn't be necessary any more, since the match would necessarily be one of the keys.