Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Easy Reference for Contexts

by LanX (Saint)
on Apr 15, 2011 at 10:11 UTC ( [id://899588]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Easy Reference for Contexts
in thread Easy Reference for Contexts

> Or rather, ANYTHING is true but undef is false.

Many things in Perl are evaluated to false in boolean context, not only undef.

Cheers Rolf

Replies are listed 'Best First'.
Re^4: Easy Reference for Contexts
by JavaFan (Canon) on Apr 15, 2011 at 10:48 UTC
    Tom is right. ANYTHING is true:
    $ perl -E 'say +ANYTHING ? "true" : "false"' true
      Ladys and gentleman, let me introduce the new "author context"!

      If you sense¹ a hidden guru identity behind a novice account, reread a post with amplified irony-factor ... ;-)

      Cheers Rolf

      1) just be careful if you see magical unicode "switches" in the text ...

      ---------------------------

      UPDATEs:

      DB<119> sub ANYTHING {} DB<120> print "false" unless ANYTHING false

      not feasible with undef.

      --------

      Funnily in Python it's easily possible to globally redefine False and True...

      > python Python 2.5.2 (r252:60911, Jan 20 2010, 23:16:55) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> False,True=True,False >>> False True >>> True False

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-23 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found