The Obfuscated Perl Contest

Dec 24

The Obfuscated Perl Contest

There’s a fascinating contest afoot since 1996 called “The Obfuscated Perl Contest.” The idea is to write the most needlessly complex Perl program your evil little mind can think up.

According to the Wikipedia page, there are four categories which tend to limit the size of the programs to just 1 or 2K. Here’s a good overview of the categories and rules.

I couldn’t find an actual home page for the contest, but since one of the categories requires entrants to print out “The Perl Journal,” that magazine probably has something to do with it. I did find a number of associated links that showed me far, far more than I wanted to know.

This guy won 2nd place. To give you an idea of how wretched these programs truly are, here’s a small piece of his explanation:

The program forks thirty-two copies of itself. Each copy is responsible for printing exactly one character from @data. Because the 32 processes are running concurrently, they somehow need to synchronize themselves so that the thirty-two characters come out in the right order. They use two mechanisms to accomplish this: First, parents wait for their children to complete before printing and exiting. Second, the processes use pipes to communicate to one another when they are finished. About half the program logic is concerned with the details of setting up the pipes correctly.

His program was just 332 characters long. I never did figure out what exactly it printed out.

This guy also won second place (I couldn’t figure out what year), but doing something even more ridiuclous: he combines two programs, then hid a subroutine to split the “true” code out and eval it.

I took half of the top portion of the code and half of the lower portion and then interlaced the characters of each. I added a for loop to the final code that separated the two halves, concatenated them, then called eval() to interpret the original program.

Now, I don’t know if that’s cheating or not, since he’s doing things that serve no purpose other than to make things difficult. I would think that extra points would be given to techniques that had an actual purpose separate from the contest itself.

I really liked this guy (man, “this guy” is apparently one hell of a Perl programmer…), who also used the “extracted string which is eval’d” technique, but which resulted in an ASCII clock which displays the current time. Very nice, and perhaps even useful.

From the Wikipedia page, I found this related page about the apparent joy of writing Perl programs to print out “Just Another Perl Hacker”. There are some examples there that are very intriguing, including the last one which appears to be nothing more the a block of Perl keywords. How that might work, I haven’t the first clue.

Maybe they should talk to the guy who writes Perl in latin. Wouldn’t that be obfuscated enough? Or how about the wicked soul that wrote the definitie guide on How to Write Unmaintainable Code? There are some techniques in there that would be worth exploring.

In the end, I can’t disagree with this post to a Perl list-serv. When confronted with the title “Obfuscated Perl Contest,” this poster responded:

isn’t this an oxymoron?

I’m with him.


Comments

by Jonathan M. Hollin,   December 26, 2004 7:50 AM  

As I was reading this post I just new that I had to comment along the lines of, "isn't every Perl program obfuscated?"

Then I read "isn't this an oxymoron?".

Right on!


by Adam,   March 2, 2005 9:58 AM  

Do you mean "tautology" rather than "oxymoron"?


by ray,   April 15, 2005 6:55 PM  

i think you mean "isn't this redundant?"

keep pratce!!1



Add Comment


Want to advertise on this site? Contact FM.
Laser Toner Cartridges UK laser toner, toner cartridges, hp toner, lexmark toner, samsung toner, canon, toner, epson toner, oki toner, kyocera toner, xerox toner, remanufactured toner, compatible toner
Direct TV Deals Free 4 room direct tv deals. no equipment to buy. free fast professional direct tv installation. this is the best direct tv deal available anywhere.
SEO Article Learn from the experts with our SEO article.
rope light Shopping with birddog distributing, inc., gives you access to the lowest prices, the best customer service and the quickest delivery times possible.
Laptop AC Adapter We offer genuine factory direct replacement AC adapters.
Direct TV Best satellite TV deals.
Direct TV Deals Direct TV programming deals are varied and include packages containing from 50 channels up to over 250 channels.
8mm film to DVD Retain family memories with the only frame by frame digital restoration service in the United States for your 8mm film to DVD today
Rubber Stamp Shop for custom self-inking stamps, hand stamps, address stamps, label stamps, check endorsement stamps, check deposit stamps, date stamps, pre inks, pocket stamps, ink and much more!