I'm starting to have fun with subroutines. Here's a little JAPH I did up to explore some possibilities.
#!/usr/bin/perl -- -*- cperl -*- sub a{my%v=map{($w[$_],$_)}@w;my$n;sub{$v{$b}<=>$v{$a}; ++$n}};sub _{my$v=shift;sub{$\=$v;$_='';}}@w=sort{&a->( $a,$b)}map{_($_)}split//,"erl hc\nker.aPust another J"; for(@w){&$_;print;}
I'm not sure how portable that is; I've only had the chance to test it on Perl 5.6.0 on Linux. The platform probably doesn't matter, but the Perl version might. Anyway, I think it shows the obfuscation potential of subroutines, especially in terms of using unnatural divisions to put things in different routines that go together and put things together that belong apart :-)
Exegesis is welcome, but stick it in readmore tags just in case people want to work it out on their own. (Not that something this short will take anyone very long...)
Update: Corrected silly sigil typo in code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fun with subroutines
by LAI (Hermit) on Apr 16, 2003 at 16:52 UTC | |
by jonadab (Parson) on Apr 16, 2003 at 17:18 UTC | |
by nothingmuch (Priest) on Apr 17, 2003 at 00:24 UTC | |
by jonadab (Parson) on Apr 21, 2003 at 20:57 UTC | |
|
Re: fun with subroutines
by nothingmuch (Priest) on Apr 16, 2003 at 14:33 UTC | |
by jonadab (Parson) on Apr 16, 2003 at 15:38 UTC |