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   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Here's hoping you don't become a robot!

Reply via email to