develooper Front page | perl.fwp | Postings from December 2001

Re: tri-state flags

Thread Previous | Thread Next
Bernie Cosell
December 5, 2001 04:42
Re: tri-state flags
Message ID:
On 5 Dec 2001, at 11:34, wrote:

> On Wed, Dec 05, 2001 at 05:11:43AM -0500, Michel Lambert wrote:
> > > defined $flag && !$flag
> > > So, who does better?
> > 
> > 
> > defined ($var = $flag) && !$var
> > 
> > $flag is only evaluated once. :)
> But Bart said he wanted to test for 0. The test above, and several of
> the other proposals don't distinguish between 0 and the empty string.

Well, what I thought he actually said was that the flag had one of the values 

I suppose you could then consider it a quinary flag with two other 
hidden/illegal values:  true but not 1, and false but not-numeric-zero and so 
in the '0' have to actually test for "was it really ZERO" rather than the flas-
but-not-numeric-zero case.

but from what he said, I'd think that bumming off of concluding "It is not 
undef and not true" implies "it must have been zero" is legit within the 
parameters of the challenge, no??

Bernie Cosell                     Fantasy Farm Fibers     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About