Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Writing obfuscated code

by prasadbabu (Prior)
on Sep 24, 2004 at 10:39 UTC ( #393441=perlquestion: print w/replies, xml ) Need Help??

prasadbabu has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks

Now a days i able to see many obfuscated codes in perl monks. I got interested in solving those codes. I want to know whether it is useful in spending time in writing such codes. If so, how it is useful. Is there any rules in writing such codes.

Give some ideas in writing such codes

thanks in advance

prasad

Replies are listed 'Best First'.
Re: obfuscated code
by hmerrill (Friar) on Sep 24, 2004 at 11:38 UTC
    Just my opinion, but the better Perl programmer you are, the simpler (simple is the opposite of obfuscated) your code is to understand :-) You should strive to create code that is simple for everyone to understand, whether or not your code is written in Perl.

    It is useful to understand obfuscated code to see just what can be done with Perl, but I don't think there's really any use for obfuscated code. If it takes me 5 minutes to figure out what a piece of code does, than that is 4 minutes too long ;-) One of my programming teachers in college told us about the "KISS" principle - you may have heard of it - "K"eep "I"t "S"imple "S"tupid. That one stuck with me.

    HTH.

Re: obfuscated code
by theroninwins (Friar) on Sep 24, 2004 at 10:56 UTC
    Well in my point of view it is more a question of art. But if you want to get started with this have look at 20312. It should give you an idea of how to do it.
Re: obfuscated code
by davido (Cardinal) on Sep 24, 2004 at 15:06 UTC

    Writing obfuscated code, for me, was an excuse for experimenting with various features of Perl that may be useful, but not frequently used. Through writing them, I exposed myself to many of the dusty corners that one might run into accidentally otherwise. To that end, I consider the experience of writing one to be of value as a learning tool. While Obfu doesn't teach good style, it teaches style to avoid, it reinforces the logical thought process, teaches a lot about Perl syntax, and in general, helps to force one to deal with parts of Perl that are often overlooked.


    Dave

Re: obfuscated code
by ikegami (Patriarch) on Sep 24, 2004 at 15:18 UTC

    There are no rules. However, some are better received than others. Here are some tips from what I have observed:

    • Portability affects how well the code is received.
    • use strict- and use warnings-friendly for bonus points.
    • But most important by far: It must have artistic element to be interesting, and I don't mean simply formatting the code to look like something. Just look at Obfuscated Code and figure out what you like about your favorites.
Re: obfuscated code
by Jenda (Abbot) on Sep 24, 2004 at 15:29 UTC

    Of course that reading and writing obfuscations is good for you. Reading and trying to figure out what does it do and how not only exercises your brain, but it also teaches you about parts of Perl that you otherwise would not know about. It's quite possible that you will never use some of those, but you may learn something that will come handy later. Either when writing your own real code or when deciphering someone elses stuff.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://393441]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2023-09-25 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?