in reply to Flip Flop IV

I found something...
$debug = ($debug eq FALSE) ? TRUE : FALSE;
But not that it seems THAT much more elegant to me...

Update: Yeah but you all use "0" and "1" instead of "TRUE" and "FALSE". That was not my intention.

Update2: Sorry to stretch that blatant things here, but I feel like like a really novice. So in perl 5.7.1 and 5.6.0 $debug == FALSE always evals to "TRUE", while the ´eq´ operator works ok.

HOWEVER: before I used the use constant FALSE => 0; perl 5.6.0 kept complaining when used "==". No - it´s not too hot here, my computer hasn´t faulty memory nor do have I :-)

Update3: And I hope the last one. First, I would like to thank all of you who responded, you´ve pointed me the right way in a fundamental question I was convinced to know the "truth". Well. I went for the use constant solution. My perhaps nitpicking question is:

use strict; use constant TRUE => 1; use constant FALSE => 0; (use other Modules)
use constant TRUE => 1; use constant FALSE => 0; use strict; (use other Modules)
The first solution seems consistent, but the second doesn´t have constant definitions spliting up the use field.

Ciao

Replies are listed 'Best First'.
Re: Re: Flip Flop IV
by Beatnik (Parson) on Jun 24, 2001 at 21:54 UTC
    If you're testing on TRUE or FALSE, use ==.
    You should check What is true and false in Perl? on the boolean topic.
    Basically true is everything except 0, "" (empty string), undef (or statements resulting in any of the previous).
    Also check perlop on when to use eq and when to use ==. True values can be tested without actually supplying an eq or == operator.
    if ($truevalue) { print 'foo'; } Update:Removed dup info
    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.