Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: What is true and false in Perl?

by Anonymous Monk
on Apr 15, 2009 at 14:58 UTC ( #757689=note: print w/ replies, xml ) Need Help??


in reply to What is true and false in Perl?

Could Perl possibly be more ridiculous? True and False are boolean values and should only ever exist as such. "0" is not boolean, and neither is "", nor in fact are any of the examples shown above. Providing such a 'feature' comes with a very significant readability and maintainability cost that is simply not justified.


Comment on Re: What is true and false in Perl?
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 ikegami (Pope) 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 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 };

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-08-23 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (171 votes), past polls