Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Chop chop

by iamcal (Friar)
on Jun 18, 2001 at 10:21 UTC ( [id://89232]=note: print w/replies, xml ) Need Help??


in reply to Chop chop

# # 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 # $;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$;->$; +->$;->$;->$;->$;->$;->$;->$;->$;()

Replies are listed 'Best First'.
Re: Re: Chop chop
by tachyon (Chancellor) on Jun 19, 2001 at 04:41 UTC

    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: note [id://89232]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-06-17 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.