in reply to Alpha-search, by letter.

No one's told you what's specifically wrong with the code you have. Not knowing what's wrong means you'll try the same things again later for a different program.

First, for $i ([A-Z]) { ... } doesn't do what you think it does. This is not a regex; [A-Z] doesn't mean "A" through "Z". For that, you want for $i ('A' .. 'Z') { ... }.

Second, s/$i/($j+6)/i doesn't execute the right-hand side as code unless you add the /e modifier: s/$i/$j+6/ie. And you'll want to add the /g modifier as well, to replace all occurrences of A with 6, B with 7, etc.

Finally, your second substitution is broken. It will replace 6 with A, but it will also change 16 into 1A. You'll need \b (word boundary) in the regex to restrict the matching: s/\b$g\b/$i/g;. And the /i modifier is useless in this case.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart