Just another Perl hacker

from Wikipedia, the free encyclopedia

Just another Perl hacker (abbreviated to JAPH ) stands for a short computer program written in the Perl programming language that only outputs the text “Just another Perl hacker”, but conceals its functionality in the source text as effectively as possible. Such a program is for experimental purposes, for the entertainment of the programmer, and has no practical use, although analyzing how a JAPH works can be extremely instructive for Perl programmers.

Methodology of obfuscation

For the purpose of concealment ( English obfuscation ), the program code usually - formulated cryptically, that its function (the output of "Just another Perl hacker") even at second glance hardly him - taking advantage of even the most absurd syntactic possibilities of the programming language Perl looks at. It is not uncommon for the source text to be given an original and completely untypical appearance for program code through creative layout. Both serve to obscure the actual function and / or the functionality of the program, or even the fact that the text at hand is actually a computer program.

history

The "programming discipline" JAPH was probably founded in the early 1990s by Randal L. Schwartz , who always had a JAPH in when posting to the newsgroup "comp.lang.perl" (predecessor of today's newsgroup "comp.lang.perl.misc") integrated his signature . Even today, JAPHs are either developed as part of programming competitions (e.g. the Obfuscated Perl Contest ), or just for fun - as a creative finger exercise for Perl programmers.

Examples

A Perl program for "Just another Perl hacker" would typically look like this:

print "Just another Perl hacker";

Concealment ( Obfuscation ) can be achieved for example by including this - understandable in itself - statement in opaque and functionless Code:

$_='987;s/^(\d+)/$1-1/e;$1?eval:print"Just another Perl hacker"';eval;

A JAPH can also look like pure garbage, although it actually contains both the characters to be output and the code for their output. In this case, the code to be output was jumbled up and the Perl one-liner sorts the text back for output:

$_="krJhruaesrltre c a cnp,ohet";$_.=$1,print$2while s/(..)(.)//;

Some JAPHs are less difficult to understand, but seem to serve a completely different purpose than the output of "Just another Perl hacker". In the following example by Randal L. Schwartz, the text to be output was recoded with a fixed text string. The one-liner only reverses the recoding:

$_ = "wftedskaebjgdpjgidbsmnjgc";
 tr/a-z/oh, turtleneck Phrase Jar!/; print;

The following JAPH program by Eric Roode , which can only run under Unix, consists exclusively of special characters; Alphanumeric characters and spaces are completely absent.

`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`

The program below by Mark Jason Dominus won 2nd prize in the fifth Obfuscated Perl Contest . From the backwritten text embedded in the source code (right in the first line), it creates the output “Just another Perl / Unix hacker” in a deliberately complicated manner.

@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print

The following program is a " bilingual " JAPH: The code can be executed by both the Perl interpreter and the interpreter of the esoteric programming language Brainfuck . The output in both cases is “Just another Perl Hacker”. The large block with the plus and minus signs is essentially the brainfuck code (with a reduced set of instructions), the first line is Perl code and implements a brainfuck interpreter for this reduced set of instructions.

/[+-]/&&eval"\$/$_$_"||/\x2e/&&print chr$/for qw!
=================================================
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + .
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + . - - . + . -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - . + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + .
+ + + + + + + + + + + + + . + . + + + + + . - - -
- - - - - - - - - . - - - . + + + + + + + + + + +
+ + . - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - . + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + . + + + + + + + + + + + + + + +
+ + + + + + . + + + + + + + + + + + + + . - - - -
- - . - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - . + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + . + + + +
+ + + + + + + + + + + + + + + + + + + + + . + + .
+ + + + + + + + . - - - - - - . + + + + + + + + +
+ + + + . - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - + + + + + + + + - - - - - - - -
=================================================
A bilingual JAPH. Valid code in Perl & brainf***!

See also

Web links

Individual evidence

  1. Detailed explanation of the penultimate example (English)
  2. Brief explanation of the last example (English)