in reply to Re^3: What could make "()" a good value for boolean false?
in thread What could make "()" a good value for boolean false?

…Maybe this is what is meant?

perl -le 'sub bingo { return 0 }; @a = bingo(); print @a ? "True" : "F +alse"' True

Replies are listed 'Best First'.
Re^5: What could make "()" a good value for boolean false?
by Anonymous Monk on Mar 31, 2016 at 07:54 UTC

    Yes (although strictly speaking, that's an array in scalar context), and also

    $ perl -wMstrict -le 'sub foo { print wantarray?"list":"scalar"; return 0; }; print( (()=foo()) ? "true" : "false" );' list true

    (although strictly speaking, that's a list assignment in scalar context). But there's also perlsyn (emphasis mine):

    The number 0, the strings '0' and "", the empty list (), and undef are all false in a boolean context. All other values are true.

      That doesn't check if () is true or false. Change it to ($x) or @a and you'll get exactly the same result. That check if = is true or false, which check the number of elements on the **RHS** of =.

      That passage is poorly worded, leading to people like you quoting it as it says something other than it says. When it says (), when it says "()", it's actually referring to "the value returned by () in scalar context, which is the same thing as saying undef. () is not a value. It shouldn't list one of the many many operator that can return something false in scalar context.