Note that the central loop is just a big serious of
whenstatements. I suspect quite a few of my old Perl 5 scripts have inner loops which would be most naturally expressed this way. The first
whenis just to automatically pass on lines with comments, none of which I wanted to mess with. The second just transforms lines with strings by applying the letter counting
substfrom the previous script. The third just copies anything else over.
This doesn't result in a working Euler script -- I still needed to go through and change it from working with the now missing strings to the new numbers. But it did all the grunt work for the change.
This makes the Euler #17 code run about twice as fast. Next up is getting that sort statement out of the inner loop...