http://www.perlmonks.org?node_id=757689


in reply to What is true and false in Perl?

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: What is true and false in Perl?
by ikegami (Patriarch) on Sep 15, 2009 at 18:10 UTC

    "0" is not boolean, and neither is "",

    Noone said they are. It was said they are false.

    Providing such a 'feature' comes with a very significant readability and maintainability cost that is simply not justified.

    That's odd. Perl, Python, PHP, C, C++, JavaScript, VB and the 5 or 6 CPU I know work that way. The only language I know that doesn't is Java.

      Also LISP.
Re^2: What is true and false in Perl?
by runrig (Abbot) on Apr 16, 2012 at 16:17 UTC
    True and False are boolean values and should only ever exist as such.

    You and your silly two valued logic. Now go away or I shall taunt you a second time!

    I never said True and False were the only boolean values!

    Update: You didn't actually say that. But that's how you should have replied to this post, if I were to respect your opinion at all, not that you'd care whether or not I respect your opinion, nor do I care whether you care ...

    Really though, thank goodness we don't have to say if ( $is_foo == TRUE ) (although, sadly, some "programmers" still do...)

Re^2: What is true and false in Perl?
by Anonymous Monk on Aug 10, 2009 at 19:26 UTC
    I love this 'feature'. It allows code like the following:
    while (@array) { my $whatever = shift @array; # process $whatever; }
    The loop ends when the array is empty.
Re^2: What is true and false in Perl?
by Anonymous Monk on Sep 15, 2009 at 17:27 UTC
    Then don't use it.
Re^2: What is true and false in Perl?
by Anonymous Monk on Sep 10, 2013 at 15:25 UTC

    Add the following line to your program, then PERL will work as you prefer, grasshoppah.

    use constant { TRUE => 1, FALSE => 0 };