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