in reply to simple letter substitution according to hash
IIUC
s/([[:alpha:]])/$hash{$1}||$1/ge;
I would also avoid capturing:
s/[[:alpha:]]/$hash{$&}||$&/ge;
but so many people dislike it, so I gave the one with capturing first. Of course tr is generally better suited for this kind of task, as explained in in perldoc perlop, but unfortunately the transliteration table is built at compile time, so you can not ionterpolate data into it. But you can adopt the eval workaround also described in perldoc perlop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simple letter substitution according to hash
by ikegami (Patriarch) on May 16, 2006 at 15:15 UTC | |
by blazar (Canon) on May 16, 2006 at 15:19 UTC |