|Don't ask to ask, just ask|
Writing highly obfuscated code in Perlby marko (Beadle)
|on Jun 29, 2000 at 05:49 UTC||Need Help??|
How do I write messy (and sometimes entertaining code code?
The first thing you will probably notice is that this tutorial is a bit Obfuscated. I thought I would match the theme :) Often one may ask how to write highly obfuscated code in Perl. Its easy to write code. But can you write unreadable code? This is a simple tutorial guide, if you want to become a pro, practice your art.
1) Take advantage of Perl's end of line character ";". Use it to dirty up your code. For example, if you want to go for a certain shape you can use ";"'s to spruce it up:
Languages that use ';' as a "end line" character are generally better for obfuscated because you can mush your code like so:
You can also make an off beat pattern for your ';''s to add a bit of confusion, like so:
2) Always break up your equal signs. Ie:
Try to do:
3) Don't forget that, if you need better "shaping", always break up your strings with a new line character "\n";
4) Regular expressions make for messy code, and that is what we are going for. Use them in excess whenever possible.
5) Add comments. Sometimes adding odd comments here and there can help enhance the shaping of your code. An example of this is found in my work : "modern (perl) art" in the Obfuscated Code section of www.perlmonks.org. However,never comment in a way that would clarify your code.
6) Try to name your variables in a simplistic, yet inconherent way. "woodzy" has done a great job of this with his work called "Email sig. Old news. :/" on www.perlmonks.org. For example:
instead of $payroll, try $p instead of $atom, try $a
7) Keep working. Practice enough and you WILL get good results. Someday you will even do lettering. You don't beleive that thats possible? Check out "Yet Another Perl Conference" by Erudil and you will see what I mean.
8) Keep your code as mathematical as possible. Never leave a simple expression alone, ie (4+4), but rather turn it into (((1*3)+1) + ((100*((1*2)+2)) /(10*10))). Doing this will make your code unreadable real soon.
9) Packing and unpacking will cause your code to be just a bit more unreadble. You will find many examples of this in www.perlmonks.org Obfuscated Code board.
10) Be sure to view some of the code found in Obfuscated Code section of www.perlmonks.org, its real helpfull on giving you some ideas on where to get started at making your code more un-readable. Please note that this is by no means a complete tutorial. I really hope that some other "perl obfuscator" will jump in and write a tutorial much better than this.
Thank you and have a good obfuscated night.
Edit 2001-04-03 by tye