Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Some additional tips...

  • First, think of something interesting to do. Second, think of an unobvious way to accomplish it. Then start writing the code. With an obfuscated algorithm from the get-go, and code that does something interesting, your obfu will be sure to please.
  • Avoid using
    if (condition) { foo; } else { bar; }
    when you can instead use the trinary operator: (condition)?foo:bar;. This is especially important when you have nested conditionals.
  • Try to model parts of your code around paradigms that a lot of people aren't familiar or comfortable with, such as functional or logical programming. Combine these with often-poorly-understood data structures if possible. For instance, having map generate a hashref of closures each iteration is sure to confuse at least some of the people reading your code.
  • Include POD that is simultaneously cryptic and actively misleading.
  • Play strange games with context and precedence.
  • Abuse symbolic references.
  • Include at least one red herring, but make sure that it is just as obfuscated and hard to follow as the rest of the code, so that it will not be immediately written off as a red herring.
  • While writing your code, go ahead and use obfuscatory techniques, but keep some line breaks and comments in so you can keep track of what you're doing; once you get it working just the way you want and nicely obfuscated, then remove the comments, golf it down a little, and alter the whitespace to reform the code into the shape you want; test after every couple of changes to make sure it still does what you want.
  • Don't break up into subroutines at the natural places; leave things inline that in real code would be better broken out as subroutines, and instead break things out as subroutines that would be better off inline in real code. Make sure your subroutines do things with the caller's variables, if possible.
  • Try to use hashes and arrays with the same single-character names as the scalars you are using, especially any punctuation-named special variables you are abusing.
  • When using regular expressions, don't use regular /slashes/ as delimiters; find more interesting characters for that, preferably ones that are also used for other things both within the regexen (where they will have to be escaped) and near them in the code.
  • Abuse the /e modifier with regex substitutions.
  • Nested string eval can be fun; combine it with $_ and substitutions to create self-modifying code.
  • Use things for multiple unrelated purposes. For instance, if you have an array or hash that you happen to know contains some elements, you can grab it in scalar context any time you need a true value. Similarly, any variable that you know contains a non-numeric string can be used as zero in numeric context. Apply this principle as often as possible, in as many different ways as possible.
  • Converting foreach and even while loops into map will often shave off several characters, with the added benefit of allowing you to assign the result to an array (or hash!) which you can subsequently use as a red herring, a true value in boolean context, or even as a number.
  • Golf, but don't overgolf. Frequently the absolute shortest way to say something is not the most confusing.

  • "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

    In reply to Re: Writing highly obfuscated code in Perl by jonadab
    in thread Writing highly obfuscated code in Perl by marko

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-03-28 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found