http://qs1969.pair.com?node_id=45592

Emboldened by my deciphering results of yesterday (and inspired by this), I decided to create the first (AFAIK) palindromic JAPH. Though the algorithm isn't terribly obfuscated, I took a harder route by not including any comments in the code, because otherwise you could do something like
print "Just another Perl hacker,\n"; # ;"n/,rekcah lreP rehtona tsuJ" tnirp
So everything you see here is parseable by perl (although, as the saying goes, I'm not quite sure why it is).

Each line is character-reversed, with the exception of parentheses and braces (which are balanced), and the slash chars "/" and "\", which are exchanged for their counterparts, because it just looks better.

$_='=_$ JustsuJ anotherehtona PerlreP hacker,rekcah ;'; @ tilps=split ; ;shift@tilps;split@tfihs; ;split@pop;pop@tilps; ;s{^(.+)(.)(.)\2.+$}{$1$2$3}s||1for@tilps;split@rof1||s{3$2$1$}{$+.2/( +.)(.)(+.)^}s; print$_.$",for@tilps;print$/ ; \$tnirp;split@rof,"$._$tnir +p ;";

Replies are listed 'Best First'.
Super Spaceship Operator
by chipmunk (Parson) on Dec 08, 2000 at 02:21 UTC
    Very nice! The way you mirrored the text is very pleasing, and the substitution and its reflection are very clever.

    I would like to stake my own claim to having the first symmetrical JAPH, though.

    This code was actually written to demonstrate a little-known operator in Perl. Of course, you're familiar with the "spaceship operator", <=>, so named because it resembles Darth Vader's TIE Fighter in Star Wars. Well, this code uses the super spaceship operator, <<=>>.

    1. < 0, push @ tnirp => <<=>> <= print @ hsup ,0 > .1 Just another Perl hacker rekcah lerP rehto +na tsuJ ; print @ tnirp ;
    That was written in September 1999, and was inspired by something Benjamin Holzmann wrote for The Perl Conference 3.0. There is a more complicated version which doesn't print the reflection, but it's not as aesthetically pleasing, so I prefer this one.

    An obscure bug in 5.6.0 forced me to rewrite my script for that version (the bug has been fixed for 5.6.1). Fortunately, the super spaceship operator still works.

    .1 . m || <= 0, push @ tnirp => <<=>> <= print @ hsup ,0 => || m . + 1. Just another Perl hacker rekcah lreP rehto +na tsuJ ; print @ tnirp ;
      For those that do not grok this delightful Perl obfuscation, I unveil the secret of <<=>>:
      print <<=>> 1; text print "done\n"; # is actually print << "BLANK_LINE" => > 1; text BLANK_LINE print "done\n"; # is actually print << "BLANK_LINE", > 1; text BLANK_LINE print "done\n";
      And the comma is superfluous.

      japhy -- Perl and Regex Hacker
      I stand corrected! Nice examples, there.
Re: lp.hpajnilap.palinjaph.pl
by Dominus (Parson) on Dec 14, 2000 at 09:29 UTC
    Great work.

    By the way, the program that inspired you was written by Brian Westley in 1987. It was the winner of the "Best Layout" award in the first International Obfuscated C Code Contest. Brian Westley has won seven times since then also.

    Westley's program is worth a close look, because there's more going on there than meets the eye.

    IOCCC Web Site for more complete details.