Nice work on the deconstruction.
Just a few observations on the deconstruction. If you look very closely at the remapping
ord comparision, it's actualy a little different from what you explained.
It's based on
meowchow's mapping function which expands a list of letters into a longer list. The trick was to take lower-case values and "double" them in the output map. Just to hide the obvious ASCII value used for 'Z' which is 90, I used 0130. Note that 0130 is
octal 130, which is actually 88 and that corresponds to 'X'. That's close enough in this example, which has no 'X', 'Y' or 'Z' in the input data.
Secondly, I think you incorrectly parsed the
map. What it has to do is either return
two copies of
uc or it has to return a single copy. The ternary operator works like this:
(ord > 88? uc : ()), uc
Note that if the letter is lower case, you will get two
uc list entries, otherwise you get an
empty list which is not the same as
undef. Also, the
uc is important since some of the letters are lower-case. Your equivalent would be:
if (ord($_) > 88)
{
return $_; # 'A' -> ('A')
}
else
{
return uc($_), uc($_); # 'a' -> ('A','A')
}
As for how the indexes were computed, check out the
original thread and see how this solution evolved. The one I used was from
meowchow, but it too is based on others.
I just had to spice things up a bit with
\s+\s++s+... It is a huge red herring. The leading backslash just returns a reference to the substitution result code, the trailing plus is for addition with the
tr operator, and may as well be a comma or even a semi-colon. Using plus as a delimiter made it extra confusing, I thought. Oh, and the 's' on the end is also functionally useless, a decorative element thrown in for the sake of having one more 's'.