in reply to Translating letters

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".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Translating letters
by DaveMonk (Acolyte) on Apr 15, 2012 at 17:42 UTC
    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)
      But eventually it will look messy (I think)

      That doesn't look "messy" to me? Maybe you could post an example of what you think it might "eventually" look like?


      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".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        Thanks, I did half of the tr/ with a range and the other half normally for each char I wanted to replace with :-)