Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Careful Evaluation

by VSarkiss (Monsignor)
on Jun 15, 2001 at 00:49 UTC ( [id://88623]=note: print w/replies, xml ) Need Help??


in reply to Careful Evaluation

All right, nobody else has, so I'll take the bait. ;-)

For those who may not have seen them before (*cough* young whipper-snappers), uuencode and uudecode are encoding and decoding mechanisms that were originally developed to allow transmitting binary files via uucp over lines that were not always eight-bit-clean. Just like MIME.

Now, on to the real decode. I've separated the lines to make them a little easier to read.

# # Set $$ -- usually the PID of the running Perl, but not a read-only # variable -- to a strange string: first part looks like code, # but latter half looks like junk. If you uudecode the junk (minus # the embedded newline) you get: # # $_=q!$_='print "Just another Perl hacker"'!; # $$ = q{$_=unpack'u',q|L)%\]<2$D7STG<')I;G0@(DIU<W0@86YO=&AE<B! 097)L(&AA8VME<B(G(3L`|;}; # # Set $} -- another strange variable -- to another strange string. # This time the uuencoded part (again minus \n) is # # $_='$_=q!($_)=($$=~/.*/g)!'; # $} = q{$_=unpack'u',q|<)%\])R1?/7$A*" 1?*3TH)"0]?B\N*B]G*2$G.P``|;}; # # The next few lines remove embedded newlines in $$ and $} (first # and fourth lines), and set these variables to these values: # $; $_=$}; (second line) # $_ $_\n=$;; (third line, including embedded newline) # $$=~s;\n;;g; $;=q;$_=$};; $_='$_ =$;;'; $}=~s;\n;;g; # # Each of these evals executes the code in $_. Before the first, # $_ contains "$_\n=$;;" as shown above. Here are the values of $_ # after each eval completes. # eval; # $_=$}; eval; # $_=unpack'u',q|<)%\\])R1?/7$A*"1?*3TH)"0]?B\\N*B]G*2$G.P``|; eval; # $_='$_=q!($_)=($$=~/.*/g)!'; eval; # ($_)=($$=~/.*/g) # BTW, the parens and "=~ /.*/g" do nothing. # Executing this is the same as "$_ = $$". eval; # $_=unpack'u',q|L)%\\]<2$D7STG<\')I;G0@(DIU<W0@86YO=&AE<B!097)L(& +AA8VME<B(G(3L`|; eval; # $_=q!$_='print "Just another Perl hacker"'!; eval; # $_='print "Just another Perl hacker"' eval; # print "Just another Perl hacker" eval; # The final eval just executes the contents of $_ seen above. eval;
BTW, if you try to execute this in the debugger, beware: setting $$ causes it to fork. Fiendishly clever!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-05-29 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found