in reply to Re: cgi problem
in thread cgi problem

I think your explanation is slightly misleading, because of this fact:

undef ne "" and undef != 0

undef is... undef. undef means that the data does not exist at all. It cannot be quantified (it's not even "0 for none", it's "undef for non-existant"), nor can it be given any sort of string value, even if that value is an empty string.

There is something in your left hand, and you don't know what it is. There is also something in your right hand, again you don't know what it is. Can you say that you have the same things in both of your hands?

This is not really an accurate description, as undef in this case would not mean you don't know what the object is, but rather that nothing exists in your hands in the first place. I understood what you meant by your post as I understand the reasoning and the behaviour behind the use of undef, though I'm not sure somebody who knows nothing about undef would have understood the difference between undef, 0, and "".

Replies are listed 'Best First'.
Re: Re: Re: cgi problem
by pg (Canon) on Jan 04, 2003 at 05:17 UTC
    (Just to make the facts straight,) did you know that your facts are actually on my side. Let's try those two examples you gave:
    if (undef != 0) {#in number context, undef evaluates to 0, and we know + "0 != 0" does not stand. print "pg is wrong!"; } else { print "pg is right!"; }
    and
    if (undef ne "") {#string context print "pg is wrong!"; } else { print "pg is right!"; }
    Both print "pg is right!".

    Also when you say undef is "does not exist". That's also wrong.

    Look at this piece of code:
    my $a;
    The moment I said this, a memory structure, called SV structure is allocated, so $a exists, although it holds undef value.