Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Welcome to the Monastery
 
PerlMonks  

Spiraling Death: not a boustrophedon.

by Dog and Pony (Priest)
on Feb 28, 2002 at 23:51 UTC ( #148425=obfuscated: print w/ replies, xml ) Need Help??

I got the idea for this obfuscation from this utterly cool snippet by BooK, but this is in no way a rip-off. While the obfu by BooK executes code that is written as a boustrophedon, my obfu executes code that is written in a spiral, starting from the center of a code block and going outwards. Thus, the name "Spiraling Death", and the reference to boustrophedons in the title.

To examplify this, I also thought I'd better need some spiraling code, so this code will search a directory recursively, searching all files for a POD =head\d entry NAME or TITLE (case insensetive). If found, it will print the path and the NAME/TITLE of the file. Try it on your /usr/lib directory, or wherever perl has it's modules installed on your computer. The program takes the directory as a commandline parameter or defaults to the current directory. You must have File::Find installed, though.

The part before __END__ is the (obfuscated, of course) parser, that decodes and executes the spiraling code, which is of course after __END__. You can read it by finding the middle letter in both axis, then going first to the right, then down, then left, up, etc...

#!/usr/bin/perl -w use strict;#:-) @!=<DATA>;chomp @!;$_=@!;map{$_ =[split//]}@!;$ 0=1;$a=$b=int$_ /2;my$s=sub{for (0..$!){push@0, $![$a][$b]|| 0; ${$_[0]}+=$0;}} ;while($!<$_){& $s(\$b);&$s(\$a );$!++;$0=-$0;} eval join'',@0; __END__ }}close FILE;} ;_\n";last;}els 1$t && /\S/){pi "x; open(FILrf =tetub wnt{rEi( nnxs\&wnt,e,n/ ti$e;(le:: t t= xr(n)diusFsu$ h epf$'nF eihr_"e n;i .if;dnin)$a $"{y' || tf ;Fd {n)m ;)d-(fiwi\ )\>ELIF<(elihld ieman::dniF::e\ /)ELTIT|EMAN(+s

But wait! I am not finished yet. Maybe you would like to create your own spiraling code? Then you can use the following spirali(zi)ng code...

just stick whatever code you will want to "spiralize" into the variable $code, like the example shows. The number of letters in the code must be an even square (like the parser also is), like 49 (7*7), 81 (9*9) or 225 (15*15), or the program will die with a warning. This wouldn't be 100% necessary, but it made life much easier, and will produce a nice square block of code. If you are having trouble getting to an even sqaure, remember that whitespace counts too. You should avoid any newlines though. Just paste the output from this snippet after __END__ in the first program and try it! :)
#!/usr/bin/perl -w my $code = q($_="Put your code here, please!!\n"; print; exit;); use strict;#:-) @!=<DATA>;chomp @!;$_=@!;map{$_ =[split//]}@!;$ 0=1;$a=$b=int$_ /2;my$s=sub{for (0..$!){push@0, $![$a][$b]|| 0; ${$_[0]}+=$0;}} ;while($!<$_){& $s(\$b);&$s(\$a );$!++;$0=-$0;} eval join'',@0; __END__ ][$i];}print"\n";} _1);$a+=$0;}$!++;$0 $,+=$0;}last if($c= [+be($c<$l){for(0>- F+$l.";die;}my@F.=$ $c;ite must be ;.$0 t$)h'd=int($wham$l; n,1wno!my$wh=) y!)} ie,;sch;lengs)r$);f rd+)i w)=mytq{oc{fo po+2 f$el$ hrpo=$or {cc/"o(doc$(trt0Fr( )$$h. fi;)l$(i ;[(0 +(,w htgneL"tnn$$0. +re$l$." ,rebmu0a.. itd(tni=b$=a$;1=].$ $soc$(rtsbus=]b$[$# ;bus=]b$[]a$[F${)!F hw$<i$;0=i$ym(rof{)
The silly example should produce this:
; exit; tre, pl net yoe ihu$_ua r P"=rs pedoc e ;"n\!!
and when run with the parser, print a message before it exits. Yep, very contrived. :)

Tips: If something seems to not work, you can add the classic ... or die "$@"; to the last line of the parser, the one with the eval. If something went wrong with the execution of your code, this will show something. Not that it most likely will help much, in this case...

This was all I had for today, and I hope someone will like it. :)


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Comment on Spiraling Death: not a boustrophedon.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://148425]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-04-17 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (450 votes), past polls