|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: char substitution without regexesby TomDLux (Vicar) |
| on Sep 30, 2010 at 20:25 UTC ( [id://862849]=note: print w/replies, xml ) | Need Help?? |
|
You said you wanted different thinking .... ikegami shows how to generate the map for one character. Use that to generate a set of maps for all possible two character strings, use that to generate a set of maps for all three character strings. When you reach the length of the input string, do a hash lookup, and voila! Obviously slower than doing one string with tr///, but maybe worth it if you have a large number of strings to process. As Occam said: Entia non sunt multiplicanda praeter necessitatem.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||