tr/abcd/1234/; #### my %tr = ( a => 1, b => 2, c => 3, d => 4 ); my $tr_keys = join('\E|\Q', keys %tr); s/(\Q$tr_keys\E)/$tr{$1}/g;