An annotated translation, into regular Perl, and layman’s terms, of the nugget of (apparent) nonsense I sometimes drop into my email signature.
For the uninitiated, JAPH stands for “Just Another Perl Hacker,” – it’s a tradition, amongst Perl programmers, to create tiny programs to output those four words in the most outlandish and esoteric of ways.
I chose to use the Lingua::Romana::Perligata module, which allows you to write your code in Latin, instead of the normal Perl syntax.
1 2 3 4
Pretty nasty, even if you know Perl and Latin.
Now let’s format it, BSD/Allman style, still in Latin:
1 2 3 4 5 6 7 8 9 10 11 12
Okay, that almost looks like a computer program. And it still compiles (at least, it does here, in Perl v5.8.4 on Debian). Now let’s see what it would look like in regular Perl – without the Latin insanity:
1 2 3 4 5 6 7 8 9 10 11 12
Calm down, I never claimed it was good code. The object of the exercise was to produce four lines of text with the ability to both bewilder, and compile!
The documentation is pretty good, but the key points to understanding it are:
The three variables @x, $x and $y are translated as xis, xo/xum (depending on case) and yo/yum (again, depending on case). The -um suffix indicates the accusative case, -o is the dative. Ah, high school Latin…
And yes, it’s a particularly evil feature of Perl which allows me to have two completely unrelated variables called @x and $x. And yes, the elements of @x would be referred to as $x[$_], which would still be nothing to do with $x. Anyway, back to the Latin:
da xis Just tum another tum Perl tum hacker translates as “give Just and then another and then Perl and then hacker to @x”. da is approximately the same as the equals (=) assignment, and tum in this context is the equivalent of a comma.
dum .. fac is the while() loop, and sic .. cis are the equivalents to braces in regular Perl. xis decapitamentum damentum xo translates as “behead @x and give it to $x”. Nice.
Within the while loop, xum scribe egresso is “write $x to an exit”. We then “write a hole to an exit, unless $y is equal to 3″.
$y? Where did that come from? How could it be equal to 3? Ah, well Perl will magically declare it for us at this point, with a value of null. So it can’t be three yet…
yo preincresce. “Increase $y”. Aha. On the first iteration, it will add 1 to null, which in this case makes 1. So on the fourth iteration, we print ‘hacker’ (the 4th array element), but not the space afterwards, since $y is 3.
This ends the while() loop, and now we just XLIV indementum scribe egresso. Or “give a name to 44 , and write it to an exit”. 44 is the ASCII code for a comma.
Oh, and why did I have to use chr() just to print a comma? Simply because the module didn’t seem to provide a “clean” way of doing it.
Phew. No more Perl for at least a week, I promise!