Front page | perl.fwp |
Postings from December 2001
Re: tri-state flags
Thread Previous
|
Thread Next
From:
Michael G Schwern
Date:
December 5, 2001 01:32
Subject:
Re: tri-state flags
Message ID:
20011205043249.I14333@blackrider
On Wed, Dec 05, 2001 at 03:30:07AM +0100, Bart Lateur wrote:
> I often use tri-state flags, with possible value true (1), false (0), or
> undetermined (undef).
>
> The question is: how do you test for one of the flags, in particular for
> 0, without warnings?
>
> For true, it's easy:
>
> $flag
>
> For undef, it's not hard:
>
> !defined $flag
>
> But for 0?
At the risk of being prosaic:
sub is_false ($) { defined $_[0] && !$_[0] }
--
Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/
Perl Quality Assurance <perl-qa@perl.org> Kwalitee Is Job One
Here's hoping you don't become a robot!
Thread Previous
|
Thread Next