Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Slashdot lamejoke generator

by Notromda (Pilgrim)
on Oct 02, 2003 at 18:15 UTC ( #296005=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Slashdot lamejoke generator
Select or Download Code
Re: Re: Slashdot lamejoke generator
by Notromda (Pilgrim) on Oct 02, 2003 at 18:18 UTC
    Oh, forgot to mention the (ab)use of => as a substitute for the comma seperator.
Re: Slashdot lamejoke generator
by jonadab (Parson) on Oct 04, 2003 at 00:14 UTC
    I'm getting lost in all the map transforms

    But, there are only a mere eight of them...

    There's some stuff that is unused... disinformation?

    I included that stuff for three reasons. (SPOILERS:

    )

    this bit of code is a fun transformation

    Yes, I initially wanted to golf that down a little more and/or obfuscate it a little better, and possibly apply it to more of the text, but I ran out of steam.

    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.

    Whenever it prints out a string, actually. The only reason it only happens once per run is because it only prints one string per run. When I was developing the thing, I had a loop that for testing purposes called all of the closures, and so !\n was printed after each.

    That's the first time I've ever de-obfuscated a program.

    Addictive, isn't it? The first time I deobfuscated something from Perlmonks, I went nuts afterward and compulsively deobfuscated the next several obfus in a row. It was a couple of days before I wanted to look at "normal" code again.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      I included that stuff for three reasons.

      Actually I guessed the first two, and the third makes sense. I was equally impressed by the :: sub name.

      When I was developing the thing, I had a loop that for testing purposes called all of the closures, and so !\n was printed after each.

      Heh.. well, to de-obfuscate the thing, I put in some Data::Dumper statements. It made the output interesting! :lol:

Re: Re: Slashdot lamejoke generator
by jonadab (Parson) on Mar 23, 2004 at 19:40 UTC
    2,0,3,1,0,0,0,0,5 is the order

    I was looking at this again (due to an issue someone was having) and happened to notice something I missed before: you parsed this incorrectly. The reference to @; occurs in scalar context, so you get 4 not 0,0,0,0. It always helps to pay attention to context. HTH.HAND.


    ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-08-23 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls