Excellent work, sir. Just a few comments:
> 1+s/\S+ /$"^$"x4|$&/eg.
> # Change all words except the final word (s/\S+ /...eg/) so that they are
> # increased to length at least 3 (the word with its space is logical-or'ed
> # with ($"x$")x4, i.e. 4 nulls).
Actually, thanks to a somewhat strange accident of operator precedence
('x' is kind of like multiplication), this ends up being $"^($"x4)|$&,
which is "\0 ". Thanks to the fact that the only capital letters in
the test input were the first letters of words, this allowed me to
preserve case while still padding with spaces.
> (s/[^ .]+ */shift@F|$"x18&$&/eg,
> # Now adjust the sentence to turn it into the second line. For each word in
> # it, replace the word by the next word statistic, logical-or'ed with as many
> # spaces as there are in the word to pad the statistic out to the right
> # length. At least, that's what's meant to happen, but there are two bugs.
> # First, the maximum number of spaces is set to 18, whereas up to 58 may be
> # needed.
I recognized this, but decided not to change it as long as the tests
didn't catch it. If only 9 had been enough, I could have saved a stroke.
> # Secondly, $" & $& produces null when $& is a capital letter, so
> # the
Once again, the fact that only the first letter may be capital came to
my rescue.
Actually, there's one more bug as well here. If any of the tests had
contained a '.' in the middle of a word (allowed by the rules, I think),
"s/[^. ]+ */.../" would have stopped too soon. Taking the rules to be
defined operationally by the tests rather than formally by the web-page
saved me in quite a number of ways. It's a low blow, but when you're up
against aliens, down to one eyeball, and plumb out of ideas...
/s
BEGIN{open$^W=0;$_=join'',<0>;s/^.*?}\n//s;$_=unpack'u',$_;s/(...)(.)/
($o,$l)=unpack'SC',$1;$r.=substr($r,$o,$l).$2/eg;eval$r;exit}
M````<````'(```!I````;@```'0````@````(@```$H```!U````<P`$`F$`
M`P%O``0!:````&4``0$@````4``1`FP`!0%H``P!8P```&L`$0(N````7``#
*`2(````[````"@``