Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Chop chop

by tachyon (Chancellor)
on Jun 18, 2001 at 07:38 UTC ( [id://89226]=obfuscated: print w/replies, xml ) Need Help??

Another one for budding deconstuctors.

tachyon

s$$,kcah HPAJ rehtona tsuJ$; (($$)->(($$)->(($$)->(($$)-> (($$)->(($$)->(($$)->(($$)-> (($$)->(($$)->(($$)->(($$)-> (($$)->(($$)->(($$)->(($$)-> (($$)->(($$)->(($$)->(($$)-> (($$)->(($$)->(($$)->(($$)-> (($$)->(($$=sub{print chop}) ))))))))))))))))))))))))));; s$$\nrekcah rehtona tey morf $;$;=$$;$;->$;->$;->$;->$;-> $;->$;->$;->$;->$;->$;->$;-> $;->$;->$;->$;->$;->$;->$;-> $;->$;->$;->$;->$;->$;->$;()

Replies are listed 'Best First'.
Re: Chop chop
by iamcal (Friar) on Jun 18, 2001 at 10:21 UTC
    # # put the string ",kcah HPAJ rehtona tsuJ" into $_ # s$$,kcah HPAJ rehtona tsuJ$; # # remove and print the last character of $_ 23 times # (($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)-> +(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)->(($$)- +>(($$)->(($$)->(($$)->(($$)->(($$)->(($$=sub{print chop}))))))))))))) +))))))))))))));; # # put the string "\nrekcah rehtona tey morf\n" into $_ # s$$\nrekcah rehtona tey morf\n$; # # set $; to the sub reference from the previous code # $;=$$; # # do the same as before # $;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$; +->$;->$;->$;->$;->$;->$;->$;->$;()

      Sure all it basically does is chop off the last char in $_ and print it. The s//foo/ construct to set $_='foo' has been a bit of a recent feature of obfus so why buck the trend ;-) The interesting thing for me is how it parses?

      In the first half we have an example of precedence. Perl evals the inner-most bracket pair first, this is vital as otherwise we can not dereference the anon sub reference $$ as it does not yet exist!

      Why we can get away with the x -> x -> x -> structure and what values pass to the sub are questions worth considering and not answered by you decon.

      In the second half we do not need the parenths as we create our reference in $; before we start the dereferences.

      cheers

      tachyon

        Sorry about not really explaining how the ->()->() bit works. I'd used this technique previsouly (though the code is generated then eval'd) in more evaluation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found