in reply to simple letter substitution according to hash
A better choice is to use$_ = 'Hello World'; my %h = ( e => 'b', l => 'd', ); my $f = join '', keys %h; my $t = join '', values %h; eval "y/$f/$t/"; print __OUTPUT__ Hbddo Wordd
$_ = '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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simple letter substitution according to hash
by blazar (Canon) on May 16, 2006 at 14:43 UTC |