http://qs321.pair.com?node_id=296005


in reply to Slashdot lamejoke generator

Wow... I'm trying to pick apart how this works, but I'm getting lost in all the map transforms. Here's a few interesting notes that I've found so far... Warning: Spoilers!

There's some stuff that is unused... disinformation?
sub ::{ ; my $i=$^; ; [split /#/, join $`, map {$i^=$_} split//,pop @_ ] }
and
%_ = map { my $z = (($_|=$^O)?$_:::($_)); $_, sub { while (pop) { my $x = unpack 'V',$_ ; push @| , ($x > $_ ? $x : $_ ) } print for @| } } 1..1024; ;

this bit of code is a fun transformation:

sub _ { +(@;=>@:) = map {[split//]} @_; for (1..9) { push @: , join $&, map { shift @$_} @; } @: }
It takes an array or words, and returns an array of words. The first word of the returned array is composed of the first letters of the words in the input. the second words is composed of the second letters... and so on.

It is used here:

join ' ', @{[_(qw(oepgnf rhnuar nfarqr gu))]}[2,$?,3,$|,@;,5]
This re-orders the words output by the "_" function. 2,0,3,1,0,0,0,0,5 is the order. (Abuse of special variables here.)

Yet more abuse of special variables:

($;,$:,$,,$\,$^,$==>$~,$.,$})=
These variables are referenced below, and are set to various rot13 strings. One of which was created by the "_" function above.
One interesting side effect it the $\ variable. It puts an exclamation point and newline on the output record seperator, which I think puts it at the end of the output whenever this program is run.
I think this looks like a ROT13 mapping:
map{sub { my $i=$!; join $&, map {my $o = $i; $i = $_; $o^$_; } split //,shift }; y;a-z;n-za-m;;$_; } @$_
yes.. because it rot13's the following code:
([q"Ia Sbivrg ", "rf lbh", "Rhffvn, $: $~" ], ["Ayy lbhe $~", " ner orybat gb hf", "rq $:" ], ["$; ornh", "rq $:", "jhys pyhfgre bs $~" ], ["$|. We".'v'."gr $~","$/3. Pebsvg", "r".qq-q-.' '.$:.".$/$=. ???" ], ["Tur arkg "."$: $~"=>"ef $} vg"." rneyl",q"vba jvyy ".'or'.qq' $^ fb +ba, ohg $.$,' ] )
Substitute in the special variables above, consolidate several cancatenations, and that would result in the array or strings to output.

Finally, that array is mapped to subroutines that output a given string, and placed in a hash:

@%= map { my $die =$_; sub { print for join $', @$die[ $%,$==>$|] } }
of which one is then executed:
$%[rand @%]->();

OMG. That's the first time I've ever de-obfuscated a program. :) ++vroom! Good obfuscation, nice presentation, and funny output for slashdot readers.