in reply to zero vs. empty

To address the first part of your question, it looks like you're making the mistake of confusing definedness with emptiness. Something is defined if it has a value. Something is true if the value meets Perl's definition of true.(i.e., anything that isn't zero or the empty string)

In your case, if you need to differentiate a value of zero from no entry at all, you can do this:

my $value = param(value); print "No answer" if ($value eq ""); print "There's an answer, but it's zero" if ($value eq 0);

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: zero vs. empty
by Juerd (Abbot) on Mar 03, 2002 at 23:00 UTC

    Something is true if the value meets Perl's definition of true.(i.e., anything that isn't zero or the empty string)

    undef is false too.

    ++ vs lbh qrpbqrq guvf hfvat n ge va Crey :)
    Nabgure bar vs lbh qvq fb jvgubhg ernqvat n znahny svefg.
    -- vs lbh hfrq OFQ pnrfne ;)
        - Whreq
    

      Well, yes, but that's just an extension of what I said, since any undefined value always evaluates either to zero or the null string. So speaketh the Camel, 3rd ed., pg. 30. :-D

      Gary Blackburn
      Trained Killer