in reply to Re: Bear is driving?
in thread Bear is driving?

here is a completely cleaned up version, showing what is actually run:

Now to save some space:
The call list needs to be shortened. Since X and Y are 2 digit numbers they can be turned into characters, so by changing the part of a() where they are set:
$$_ = ord(shift) - 20 for qw.x y.;
we can then call them like this:
a"]","]"; a"?","l"; a"!","{"; a"!","]"; a"!","?"; a"!","!"; a"?","0"; a"]","?"; a"{","N"; d"]","]"
which then becomes this:
$_ = "]]?l!{!]!?!!?0]?{N"; s#(.)(.)#a"$1","$2";\n#g; /".+;/; $_ .= "d$&"; eval;
ie take two chars out of the string, and replace them with a"$1","$2";, then match the first call and use it to call d();

eval will run the calls, drawing the boxes.

To obfuscate, and save space i then did a form of huffman encoding, where repeated strings are replaced with a single letter, to do this the bulk of the program was but in $_, (using q^..^;) and then run through this:

for$r(qw.$i-> colorAllocate( Polygon shift) l@_, KK); GD 10, I sub 153, 20 new.){$l=chr 65+$c++;s#$l#$r#g}
for each of those strings in the main block, substitute the letter (starting at A (chr 65) ) with the corresponding string, so A is $i-> B is colorAllocat( etc.

finally $_ (all the code) is eval'd

Before posting i run it through my obfu formatter (which i call perlmess - the opposite of perltidy :) ), which simply reformats it as lines of 72 chars. (i also use it in development of these things as it tells me how many chars i'm at, and how many over 4 lines i am etc etc).

HTH
al

Considered by teamster_jr: I was thinking of moving this to mediations as an explanation of obfuscation. is it worth it?
Unconsidered by planetscape: keep votes prevailed (keep:15 edit:3 reap:0)