obsfucation is a kind of art,
an insane art, tough.
Anyway, i like perl obfuscation :-)
But what happens if you find some ugly unindented? ... use unix indent or other code-indenting tool? ... Yep, thats the solution for all those that do not like risks ... but for the rest, here you got a nano-script, for indenting some c code :-)
#!/usr/bin/perl
(/(?:}\s*(?:else(?{$/--})|
(?{$__="\t"x--$/.$_})))/xo,
/(?:{\s*(?{$__="\t"x$/++.$_}))$/o,
print($__?"$__":"\t"x$/.$_),
undef $__) while (<>)
¿how to use it?, very simple:
usage: indent [--help] file
example:
indent file
I've use this file for testing:
#include#include #include int main() { int pid,aux,status; pid = fork(); if ( pid < 0 ) { perror("fork"); exit(9); } else if ( pid == 0 ) { //Child printf("do nothing ...\n"); exit( 0 ); } else { printf("father\n"); do { aux = waitpid(&pid,&status); } while(pid == aux); } printf("end :-)\n"); }
Sure it's no perfect, sure it's useless ... but it's my baby monster ;-)
Dr. Frankesturein
Once I had to write a one-liner script for similar purposes when I've extracted a code snippet from a PDF document (or some other similar format, I can't remember) and the indenting and newlines got lost.
perlmonks.org content © perlmonks.org and ambrus, turo
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03