in reply to Alpha-search, by letter.
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.
|
|---|