On Wed, Jun 18, 2003 at 09:44:58AM +0100 Sparrow, Dave wrote:
> A regular contributor to the Perl Quiz Of The Week discussion newsgroup
> ([EMAIL PROTECTED]) is Tassilo von Parseval. 

Actually even more regularly to this list here so I can respond...

> His email signature is reproduced below. I have no idea what it does
> and can't get it to run.

You can't get it to run? For me:

[EMAIL PROTECTED]:~$ perl
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
__END__
Just another Perl hacker,[EMAIL PROTECTED]:~$

There shouldn't be anything platform dependent in it. However, for this
JAPH whitespace does matter. So you need to copy it as one string and
not concatenate it together. Must be three lines separated by newline.

The basic idea is simple. It has some Perl code that is backwards and that
is evaled after some processing. A common JAPH-pattern. The string is:

 ",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
 pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;

It is wrapped in '$_=q#....#;' to obfuscate it a little and to assign to
$_.

Next is

    $_=reverse,

which turns the above into

    subJust{another(qq!HPAJ!)}subanother{Perl()}subPerl{hacker()}subhacker{map
    {($_=(caller(3-$_))[3])=~s/main:://;$_}0..3}print"@{[Just(qq!HPAJ!)]},"

That now already looks more like Perl. After that a substitution against
that happens:

    s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;

Of course, the many x and s modifiers are spurious (just used to pad my
signature nicely). So actually it is:

    s/(?<=sub)./q#q!'"qq.\t$&."'!#/sieeeeeg;

This turns the above string into:

    sub     Just{another(qq!HPAJ!)}sub      another{Perl()}sub
    Perl{hacker()}sub       hacker{map
    {($_=(caller(3-$_))[3])=~s/main:://;$_}0..3}print"@{[Just(qq!HPAJ!)]},"

It is really just used to add a whitespace between the keyword 'sub' and
the function name. Writing it properly formatted yields:

    sub Just {
        another("HPAJ");
    }
    sub another {
        Perl();
    }
    sub Perl {
        hacker();
    }
    sub hacker {
        map { ($_ = (caller(3 - $_))[3]) =~ s/main:://; $_ } 0 .. 3 
    }

    print "@{[ Just("HPAJ") ]},";

The 'y~\n~~dddd;' is the same as

    tr/\n//d;   # deletes all newlines

It's not important and could be left off. Eventually we have some Perl
code in $_ and simply run it with eval().

The above code consists of one print() statement that calls Just().
Just() calls another(), another() calls Perl() which in turn calls
hacker(). Finally hacker() looks back in the caller-stack and extracts
who called whom:

    (caller(3))[3] == "main::Just";
    (caller(2))[3] == "main::another";
    (caller(1))[3] == "main::Perl";
    (caller(0))[3] == "main::hacker";

It strips off the main:: part and returns the list qw(Just another Perl
hacker) which - because it is interpolated in double quotish strings -
stringifies to "Just another Perl hacker". 
 
If you like JAPHs you should have a look at those of Abigail in
particular ('perldoc -q JAPH' links to a couple of those by him, too).
It's consensus that he has written the most obscure and funniest JAPHs
around.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to