PREVIOUS  TABLE OF CONTENTS 

The 1st Annual Obfuscated Perl Contest

Felix Gallo

Summer is in the air, and young hackers' thoughts turn to writing gloriously awful code. And yes, despite our editors' protestations, despite the restraining order, despite even explicit medical advice from our therapists, we're once again proud to bring you the infamous, world-renounced Obfuscated Perl Contest.

The objective: to determine who can write the most devious, inhuman, disgusting, amusing, amazing, and bizarre Perl code.

The prizes: a lovingly manufactured trophy made of high durability space age materials, suitable for brazen display or shameful and secretive night burial. Also ord 'd' dollars.

But wait! Before you rush to your keyboard to craft your outrè æuvre, here are the categories in which you may enter:

1. MOST POWERFUL

This award is granted to the code which does the most with the least. The limit on bytecount is 512 characters, not including whitespace.

2. MOST CREATIVE

This award goes to the most stunningly intriguing or ridiculously hilarious combination of obfuscation and functionality. The limit is 1024 bytes of Perl code, not including whitespace.

3. BEST 'THE PERL JOURNAL'

In the fine 'just another Perl hacker' tradition, this award is given to the best code which generates the text 'The Perl Journal'. Case and context are unimportant. The limit is 1024 bytes of Perl code, not including whitespace.

4. BEST YEAR 2000 ERROR

"Marsh & McLennan Inc. is offering businesses a hedge against Year 2000 problems. The New York insurance broker will sell up to $200 million worth of insurance against business losses caused by the policyholder's own computer system, or by another company's neglect to become Year 2000-compliant, or by data supplied by another company's computers. Before the policy is issued, however, Marsh & McLennan will enlist experts to make sure that the policy-buyer is taking all possible steps to avoid Year 2000 problems." (Information Week 3 Feb 97, via EDUPAGE)

It's hard to escape the conclusion that crafting obfuscated code can be not just enjoyable but profitable as well. For $200 million, can you hide a Year 2000 bug well enough to fool some insurance salesmen?

In addition to these four categories, the judges will award one applicant the coveted and yet feared 'BEST OF SHOW' award.

THE RULES

  1. All programs must run under Perl 5.004.

  2. Programs may use only the functionality included in the basic Perl distribution found on CPAN. No modules, patches, or extensions beyond those included in the standard distribution are available.

  3. Programs will be run on the judges' choice of platforms. The only guarantees about these platforms are that their interpreters pass make test, they have at least 4 megabytes of available user-space memory, and they have at least 1 megabyte of external storage. Programs may use whatever resources they find available beyond those limits, however.

  4. Submitted programs remain the credited property of the author, but may be duplicated, quoted, edited for style and disseminated freely by The Perl Journal and the contest judging committee.

  5. All programs should be uploaded by anonymous FTP to tpj.com in the directory pub/orwant/obfuscated by July 25, 1997. The tar (or zip) archive must contain the following items:

HOW IT WORKS

As last time, judging will take place in three phases.

In the first phase, we'll read the README and then examine the program carefully in order to assess its aesthetics. Any code we actually understand at this point is probably not obfuscated enough.

In the second phase, we'll run the code, examine the output, and read the code again in light of its output.

In the third phase, we will perform unnamed rituals with filters, pretty printers, debuggers, and whatever else we can think of to determine how the code works. Any code that we don't understand at the end of this phase is probably a winner, at which point we'll give up in tears and look at the SOLUTIONS file.

HINTS AND SUGGESTIONS

Judging obfuscation and what's 'cool', 'neat' or 'best' is a subjective process. However, here are some general guidelines which might help you design your entry.

Overuse of one particular obfuscation method risks being tedious. Entries which demonstrate breadth, range, and knowledge are likely to beat entries which rely on repeated parlor tricks.

Being clever and humorous is good. As an example, a past winner in the Obfuscated C contest (our pale, weaker cousin) formatted his code in the shape of a maze; the program read its own source code and implemented an ASCII 3D maze walking program.

Being surprising and deceitful is very good. Bonus points are awarded for obfuscated code which is not only syntactically obfuscated, but semantically obfuscated - code which appears to do one thing but does another is deemed extremely devilish.

Being poetic is also very good.

Entries needn't contain a #!/usr/bin/perl (or equivalent), unless they use nonobvious command-line switches. Neither the #!/usr/bin/perl nor the command-line switches will count toward the character limits.

Programs which purposefully crash machines or cause system problems tend to be unamusing, so please consider saving them for the Perl system destroyers' contest.

The best examples of quality obfuscation are the four category winners from last year's 0th Annual Obfuscated Perl Contest, shown on the next page. (Note that the 0th Annual Contest sported a Best Four Line Signature category instead of the Year 2000 category.)

SO THERE YOU HAVE IT

Please submit early and often, and encourage anyone you know who might be interested to do the same.

Although Perl has taken some hard knocks as being a write-only language (and this contest could be construed as an unabashed celebration of that fact), the intent of this contest is to demonstrate Perl's tersity and power, while at the same time giving the creative and demented minds of the Internet's legions a fun, intriguing playground. So have fun!

Although we do not accept any entries via e-mail (FTP only, as above), questions regarding this contest or its rules should be directed to contest@tpj.com.

We look forward with some trepidation to seeing your code!

The 0th Annual Obfuscated Perl Contest Winners

Best Four Line Signature: Robert Klep

$Y=-1.2;for(0..24){$X=-2;for(0..79){($r,$i)=(0,0);for(0..15){$n=$_;$r=($x=$ 
r)*$x-($y=$i)*$y+$X;$i=2*$x*$y+$Y;$x*$x+$y*$y>4&&last}print unpack("\@$n a" 
,".,:;=+itIYVXRBM ");$X+=3/80}$Y+=2.4/25}

Most Powerful: Russell Caton

$-=100;while((($@)=(getpwent())[2])){push(@@,$@);}foreach(sort{$a<=>$b}@@){
(($_<=$-)||($_==($-+++1)))?next:die"$-\n";}

Most Creative: Bob Sidebotham

# $Id: pisig,v 1.21 1996/07/08 19:35:21 rns Exp $ 
$maxerrors = 220; # needs tuning 
$pi=reverse"3.1415926535897932384626433832795028841971693993
751058209794459230781640628620899862803482534211706798214808
651328230676470938446095505822317253594081284811174502841027
019385211095559644622948954930381964428810975665933446128475
648233786783165271201909145648566923460348610454326648213393
607260249141273724587006606315588174881520920962829254091715
364367892590360011330530548820466521384146951941511609433057
270365759591953092186117381932611793105118548074462379962749
567351885752724891227938183011949129833673362440656643086021
394946395224737190702179860943702770539217176293176752384674
818467669405132000568127145263560827785771342757789609173637
178721468440901224953430146549585371050792279689258923542019
956112129021960864034418159813629774771309960518707211349999
998372978049951059731732816096318595024459455346908302642522
308253344685035261931188171010003137838752886587533208381420
617177669147303598253490428755468731159562863882353782016673
156423156323187423187323128423128323658323697323647223923101
167323156423156323287323187423128323128323158423158323197423
197323147723923101167323656323187123187223187423528323158421
583231974231973231477239231011673231564231563231872231812318
732312842312832315842315832319742319732314772392310117423456
423187323287323628323158423158323697323147723923301723923101
667323128423128323696823108823101167423128323128823196823108
823101167423528623396423508823101167323128423128823196323108
423108823101167323628323696323608823401696323127423127623142
231011963231274231276231482231019233963236276231482231011963
23127423127623148223101696323127423127423548101";

while ($offset < length($pi)) { 
    my($x) = substr($pi, $offset +++ 0, 2); 
    my($y) = substr($pi, $offset +++ 1, 1); # XXX should be 3? 
    my($z) = substr($pi, $offset +++ 2, 1); 
    if ($x * cos($y) / cos($z)) { 
        $dbg .= chr ($x) x $y; 
        if (++$errors >= $maxerrors) { 
            # "cannot happen" 
            die("$dbg\n"); 
        } 
    } 
}

# passes sig test 
print("ok!\n");

Best 'The Perl Journal', and Best of Show: Gisle Aas

*_=\$#;$/=q#(.)#;$#=10;$^X=~s|.*/||;$\=chr;$#=gmtime$#;substr($#,$^F#^F
*$^F**$^F-1)=al;s$\$/( )\$/\$/$e\$2\u\$^X\$2\$3o\$1r$ && print time

PREVIOUS  TABLE OF CONTENTS