Chapter 46. The Fourth Obfuscated Perl Contest

Felix S. Gallo

You were born into this. From the first day they swaddled you in scarlet silk blankets, put one of their own into the crib, and stole you crying away into the black stillness of the forest, you have been in a school of previously unknown purpose.

Your eyes, once childish and full of wonder, have matured all too quickly. They’ve roamed books not written to be read, murals not drawn to be viewed; they’ve watched macabre puppet theatres that portray the studied arts of deception.

Your fingers, thick and clumsy compared to theirs, have been trained to work the skeins of falsehood and lies made fabric. In the glow of the phosphorescent toadstool circle the needles flicker and glitter like shooting stars.

Poison has become your tongue. As their emissary you walk the daylight world, chatting and laughing in streetside cafes or talking to colleagues in your office; but inside the guileweave hides a venomous calculus. Every night you lay out the candles and the breadcrumbs and wait.

Today the air is different. The sun still shines, but you feel the chill of invisible clouds passing over its face. And the smell is sharper, like the taste of the dark earth at the foot of a graveyard. Today you know your decades of secret schooling draw to a close, and as the power wells up inside you, you hope that you are ready. There are four circles of judgement in which you may prove your worth as a master of deception.

The first circle is judged upon the ability to craft a lie that commands an infernal computing engine to print the words “The Perl Journal” in human-recognizable form. You may only use up to one thousand glyphs, including the invisible ones, in the completion of this screed.

The second circle is judged upon the ability to forge a deviousness that commands an infernal computing engine to perform some task of extreme might and puissance. Your limit is six hundred glyphs, whether visible or no.

The third circle is judged upon the ability to create a monstrosity that exhibits artistic cunning and creative guile in its dread formulation. The limit is one thousand glyphs, including those which cannot be discerned by the naked eye.

The fourth circle is judged upon the ability to cause your fell creation to appear as a chameleon or doppelgänger does: as a deceptive imitation of another tongue. You must pick a different language and endeavor to make your handiwork fool the eye into believing that it was written in that language. For this purpose you may select up to two thousand visible or invisible sigils.

The laws of the circles are few but severe.

  • All dweomers must be penned in the language of the fifth camel.

  • While you may use the hide, the hair, the nails, and the teeth of the pure camel, your spell may not rely upon the existence of any other animal, neither ibex, vampire bat, rhinoceros, nor warthog; nor the vile children of the palaces of Berkeley, Redmond, Finland, or New Jersey.

  • Your incantations will be pronounced within the confines of a memory cage capable of holding four million things; attempts to use more may succeed, or may shatter the cage and release your bound spirits into the air with the crashing of glass and the tinkling of tiny bells.

  • Your writings belong to you; but you provide the judges and The Perl Journal with the right to duplicate, quote, edit for style, and disseminate them freely upon an unsuspecting world.

  • Your works must be sent to the Stronghold by the first day of the eighth month. You must use the anonymous Fœtid Transference Petals to connect to ftp://ftp.tpj.com and place your entry in /pub/orwant/obfuscated.

  • The champions and their monstrosities will be announced in comp.lang.perl.moderated, in the magazine, and on tpj.com. By this iteration of the nightbird’s cycle you may be familiar with the methods of judgement. But as there are newborns amongst us fresh from the amniotic dew, I relate them here.

    First, the committee examines the work. If we can determine its nature visually, then we disqualify it as being too human.

    Second, the committee hands the work to an infernal computing engine and examines the results.

    If after this act we still can’t unravel the tortuous webs of your thinking, we examine the SOLUTION text you have helpfully provided.

    Most victors attain that rarefied third strata.

    In addition to the quality of being merely impossible to understand, much of the judgement relies on aesthetics, cleverness, newness, humor, and interest, especially manifold and in combination. As an example, many entries in the last circle relied on using a plethora of invisible glyphs—which was mirthful, but too obvious. Obvious means failure. The void faerie hungers for new toys.

Remember, you were born into this. In the underworld the leaves rustle as an unseen crowd gathers closer to the camel stone. Make your masters proud.

—Felix Gallo, Lead Inquisitor

The Obfuscated Perl Contest

Results

Fifty-seven contest entries hemorrhaged forth into our FTP directory. Previous contests have been perhaps more synapse-curdlingly intense; the hallmark of this year was sheer volume. Of course, we in the judging committee are all very relieved that the collective obfuscatory powers of the Perl community have plateaued and are now declining—some of us are even slated to eat solid food again soon! Next year promises to be trivial! This is getting so easy !

The First Circle: Print “The Perl Journal”

Third place: Tramm Hudson’s steganography entry, cleverly done (albeit misspelled)—but the very last abuse of whitespace ever to be permitted in this category, ever ever ever.

Second place: John Keating’s monolithically forbidding block of old-skool obfuscated code. Extra points for assigning to $!.

First place: Keith Winstein’s optical character recognition engine. Both judges almost figured this one out after Keith blew his cover by naming a subroutine ocr. Clever code, however!

#!/usr/bin/perl -l

print ocr(<<TPJ);
 #  # # ## ##  ## ##  #    #  #  # # ##  #  #  #  #
### # # #  # # #  # # #    # # # # # # # ## # # # #
 #  ### ## ##  ## ##  #    # # # # # ##  # ## ### #
 #  # # #  #   #  # # #  # # # # # # # # #  # # # #
 #  # # ## #   ## # # ## ###  #  ### # # #  # # # ##
TPJ

sub ocr{@{$-[$@++]}=split$,for(split'
',shift);for$@(0..4){for(0..51){++$_{$_
 }if($-[$@][$_]=~$")}}@&=(-1);for(sort{$a<=>$b}keys%_){push@&,$_ if($_{$_}>4)
  }push@&,52;for$@(0..13){@{$|[$@][$_]}=@{$-[$_]}[$&[$@]+1..$&[$@+1]-1]for(0..
   4)}for(@|){**=$_;$w=@{$*[$^=$$=0]}-1;for$@(0..4){for(1..$w){$^++if$*[$@][$_
    ]ne$*[$@][$_-1]}}for(0..$w){for$@(1..4){$$++ if$*[$@][$_]ne$*[$@-1][$_]}}
     for(0..20){push@},chr$_+65if(7*(8,4,2,9,2,3,7,8,1,$@,5,4,9,10,10,6,3,8,4,
      8,8)[$_]+(5,8,3,3,4,2,1,2,8,2,7,1,5,4,6,$@,3,6,8,4,1)[$_]==7*$^+$$)}}@}}

Dishonorable mention: Sven Neuhaus’.signature-sized entry, and Les Peters’ nicely formatted periodic table of elements.

The Second Circle: Do Something Powerful

Third place: Eugene’s sweetly concise self-printing program. Not very powerful, but pound-for-pound a contender:

$_=q(s%(.*)%$_=qq($_=q($1),$1),print%e),s%(.*)%$_=qq($_=q($1),$1),print%e

Second place: Mike Guidero’s string permuter, useful for making your screen look like something from War Games:

#!/usr/bin/perl
G:  *S=sub{goto shift};*T=sub{exit shift};*U=sub{print shift};
H:  my $A="";my $C=0;my $D=0;my $E=0;my $F=0;my $G=0;my $H=0;my @I;
I:  if(!defined($A=$ARGV[0])){U(qw(ARGV[0]?));U("
");T(1)}$C=length($A);
    U("-$A-
");$D=0;
J:  $F=0;$I[$D]=0;if($D!=$C){S(K)}for($G=0;$G<$C;$G++){U(substr($A,$I[$G],1))
    }$H++;U("	");$H%8||U("
");S(M);
K:  $F=$D;if($F!=0){S(N)}$E=$I[0];if($E==$C){U("
---
$H
");T(0)}
L:  $D++;S(J);
M:  $D--;$I[$D]++;S(K);
N:  $F=$I[$D];if($F==$C){S(M)}$E=$D-1;
O:  if($F==$I[$E]){S(P)}$E--;if($E!=-1){S(O)}S(L);
P:  $I[$D]++;S(N);

First place: Claudio Calvelli’s comp.lang.perl.announce newsreader, a monstrous piece of code that delves into 8-bit characters and still has 28 bytes of headroom.

Dishonorable mention: Robert Klep’s implementation of just one software munition, which unfortunately didn’t run on one of the judges’ machines. Note to future contestants: the new bar for crypto consideration is three or more algorithms in one program, preferably all illegal, preferably all military-grade.

The Third Circle: Be Creative

Third place: There weren’t enough quality entries to justify giving a third prize in this category. Maybe next year we’ll give two.

Second place: Art Ramos’s implementation of Windows Minesweeper. Cute, pretty clever, but…

First place: Andreas Hagelberg’s implementation of Windows Minesweeper. It’s fairly ironic that a Perl contest with a creativity category results in two implementations of a Microsoft timewaster; nevertheless, Andreas’s entry has some nifty features.

srand;for(0..5){$r[$_]=chr 65+rand 8}sub d{print$/x6;for(0..335)
{print$_<27&$_>13?'-':$_%14>12?"
":$_<6?$_[0]?$r[$_]:
'O': $_%14==6?'|':(split//,$b[int$_/14])[$_%14]||$"}print"$/Enter
m/[A-Ha-h]{6}/
"}sub c{return if/[^A-H]/||length()-6;@c=split//,
${$f=($b[24-++$w]=uc.$")};$w>21&&return 1;for(-6..35){($p[$h]=1)
&($q[$h]=1)&($$f.="*")&$n++if$_<0&&$c[$h=$_+6]eq$r[$h];
!$p[$b]&&!$q[$d]&&($p[$b]=1)&($q[$d]=1)&($$f.="+")
if$c[$d=$_%6]eq$r[$b=$_/6]&&$_>-1}(d$])&die"Done$/"if$n>5;
$n=@p=@q=()}while(!c){d|chop($_=uc<>)}d$/;print"$/Looser!$/"

The Fourth Circle: Make Believe You’re Another Language

Third place: Claudio Calvelli’s Intercal script. Intercal, Perl’s mad aunt, is just the sort of beautiful language people accuse Perl of being.

Second place: Philippe Bruhat’s wc (word count) script, which compiles both in C and in Perl, caused one judge to leap from his chair and go wash his hands obsessively.

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#define open(a,b) open(b,a)
#define $ARGV argv
#define $i i
#define x : /* aren't four #define way too much?
               unshift @ARGV, $_ = $ARGV[0]; "*/
main(int argc, char *argv[ ]) { // "; {
  int m=1, i[14]; char * pp; int p=-1;
  int q, F=3; char * qq = "Hello, world!
";
      i[12]=537463307; i[13]=3085; //,; $_ = "" if(length!=2);
  if(m+-p?(argc>1&&!strcmp(argv[1],"-p"))?p+i? 1 : 1 x 0 x 0) {
    printf(qq/*The Perl Journal
/#*/
       ); exit(0); }
  qq="=;#"; argv[0][0]=''; memset(i,0,48);
  $i[10]=($i[11]=(q/*/&&scalar@ARGV))-1;#*/=0) + argc)-1;
  do{
    if($i[11]<2) { $i[10]=1; q/*/&&*F=*STDIN;#*/=F=0;
    } else { open(O_RDONLY, $ARGV[$i[11]-$i[10]]);//; *F=*O_RDONLY;
    }
    while(read(F, $i, 1)>0) {
      ++$i[4]^(q=/*.=,$_=$i);#*/0); pp=i;
      $i[3]+=m=( *pp^0x0A)?/*
=;#*/0:1; for(qq=&i[12];*qq;*pp^*qq++||(q=1));
      if(m=/*[         
f
xB]=#*/q
        ) { if($i[1]){$i[$i[1]]++; $i[1]=0; }} else { $i[1]=2;}
    }
    if($i[1]){$i[$i[1]]++;};
    printf("%7d %7d %7d %s
",$i[3],$i[2],$i[4],$ARGV[$i[11]-$i[10]]);
    close(F);
    if($i[11]>2){for($i[1]=2;$i[$i[1]+4]+=$i[$i[1]];$i[1]++){$i[$i[1]]=0;};$i[1]=0;}
  } while(--$i[10]);
  if($i[11]>2) { printf("%7d %7d %7d total
",$i[7],$i[6],$i[8]); }
}

First place: Chris Howe’s mad, bizarre Befunge interpreter. Befunge is the sort of language they might hold a “Comprehensible Befunge Contest” for. Quite brilliant, really.

# ^
#,_:@
BEGIN{$l="ub";$_='KN($){$d=$_[0]}KL(){$B[$R][$C]}KM{$a=@{$B[$R]};
$d==0&&($C++,$C>=$a&&($C=0));$d==2&&($C||($C=$a),$C--);
$d==3&&($R++,$R>=@B&&($R=0));$d==1&&($R||($R=@B),$R--);}
KP($){push@S,shift}KJ(){pop@S||0}KX(){@S[-1,-2]=@S[-2,-1]}KR()
{push@S,$S[-1]}KW($$){"Z".$_[0]."Z,K{".$_[1]."},"}KG($){($_)=($a)=@_;
y/`/>/;W$a," X;P(J$_ J)"}KD($){($a)=@_;W$a,ZP Z.$a}KE($){($_)=($a)
=@_;y/0123/>^<v/;W $_,"N $a"}';y/Z/'/;s/K/s$l /g;my($R,$C,@S);
eval$_;}$_=$x=W '_','N(J?2:0)';y/_02/|31/;$x.=$_
#r^>"J eg"1+T,,,,l#
; $u=W '"','@T[0,1]=@T[1,0]';$_=$x.$u.W('!','P!J').W('?','P int
rand(4)').W(':','R').W('\','X').W("$",'J').W(' ',"").W('#','M')
.W('.',"pIJ,chr(32)").W(',',"pIchr J").W('@',"pI'
';exit").W('g','X
;P ord$B[J][J]').W('p','X;$a=\$B[J][J];$$a =chr J;'),s/I/rint /g;@T=eval
join"
",'({',(map{D$_}(0..9)),(map{E$_}(0..3))
,(map{G$_}split//,'+-*%/`'),$_,'},{',$u,'})';for(@B=<>){$_=
[split/
*/]}while(1){$_=L;$_=" "if!defined$_;~y/s/ /;exists$T[0]{$_}?$T[0]
{$_}->():P ord$_;M;}

Befunge is a two-dimensional language. The instruction pointer, instead of moving from one line to the next in a comforting logical sequence like every other language, moves character by character—and not always from left to right. When the instruction pointer hits a v, it moves down whatever column it’s in. When it hits a ^, it moves up. < and > move the pointer left and right. Befunge programs wend their way around the page, and the one created by Chris’ program eventually prints The Perl Journal. You can learn more about Befunge at http://www.loungelizard.com/pascal/befunge/beffaq.html.

Dishonorable mention: Clifford Adams’ use of NO CARRIER was a welcome blast from the past. ?SYNTAX ERROR, anyone?

This year’s Grand Prize goes to Chris Howe for the most creative, powerful, incomprehensible, and shapeshifty submission: his Befunge interpreter. Such attention to detail! Such painstaking mutilation! It is clear the authorities need to be made aware of Mr. Chris Howe.

Reading these entries and trying to figure them out for yourself is a great way to learn a lot about Perl very quickly (as long as you don’t pick up all the bad habits!). We strongly recommend that anyone interested in getting really good at Perl check them out.

For the relatively unscathed judging committee, thanks to everyone for making this year so simple to judge!

—Felix Gallo

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset