I wanted to know if there are quicker/better ways of translating numbers to letters. At the minute I am doing tr/etc/etc/g.
No, tr/// is hands down speed winner for char-by-bar translations where the ampping is known at compile time.
it doesn't feel nor look right when translating many many letters/numbers.
In most cases, it is possible to use the start-end range facility to produce compact and clear code.
If that is not the case for your application, post an example. You may be better off evaling a custom tr sub into existence.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
| [reply] |
Well at the moment, I am doing:
foreach (@words) {
tr/abcdef/123456/;
print @words;
}
And the contents of @words are read in from a file. But eventually it will look messy (I think) so I was just wondering of a good/better way to do it (if there are any) | [reply] [d/l] |
| [reply] |
| [reply] [d/l] |
Being in mind that there are more than ten letters you can't use really tr for this idea because tr only changes a char by another
What I want to say is that you can't use tr to change i.e "f" by "23"
Although nothing is wrong with tr, if your problem is more complex that the example that you provide you probably should think in a hash for this
| [reply] |
mmmh... you ask about traslating numbers to letters but I realize just now that every people are doing exactly the opposite, showing how to traslate letters to numbers... XD.
tr is the right tool for this, then
| [reply] |