Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Cheap obfu: or is it?

by mt2k (Hermit)
on Jun 23, 2002 at 05:14 UTC ( [id://176570]=obfuscated: print w/replies, xml ) Need Help??

Okay, I based this off an obfu I saw somewhere... I tried looking for it but couldn't :(

Anyway, BEFORE running this snippet, predict what it will output....

# Set environment variables $$=\$,;$,=$; # Begin POD documentation =cut ; ; # Usage: ; # require "script.pl"; ; print "\"You are $$$,\" said the coach."; ; =cut # Above Line Ends POD # Send the user some output print "Just Another Perl Hacker";

Replies are listed 'Best First'.
(zdog) Re: Cheap obfu: or is it?
by zdog (Priest) on Jun 23, 2002 at 18:24 UTC
    That's a pretty cute trick. Sorta reminds me of "Things are not what they seem like.".

    The key here is that the second assignment doesn't really end until the 6th line from the top. So the string 'cut' is assigned to $,.

    For the record: I did not guess the output before I ran the script. :-)

    Good stuff.

    Zenon Zabinski | zdog | zdog@perlmonk.org

      zdog++ for being able to find the node I could not come up with. Things are not what they seem like. is the node I based it on. When I saw that node, I kind of thought "yeah, that second line with the POD is cool, but a 'cut' would look much better." Then I remembered the whole thing of barewords being "allowed" in assignments.

      So I built upon that and the reason you never see the output of print "Just Another Perl Hacker"; is because the actual POD doesn't start until the second occurence of '=cut', since the first is really an assignment to a variable! :)

Re: Cheap obfu: or is it?
by janx (Monk) on Jun 25, 2002 at 22:51 UTC
    Well.... it prints Modification of a read-only value attempted at - line 1.

    At least since perl@17272 (the earliest since 5.6.0) I have at my fingertips right now ;-)

    Kay

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found