in reply to Re: defined or undef
in thread defined or undef

I am attempting to return a list, because getElementsByTagName retruns a list. In this case the list sould contain one item.

my @rtnVal = undef;
is adding an undefined element to the @rtnVal array? Oh my. Not what I expected.

Is this valid code
print ( @rtnVal ? " defined \n" : " undefined \n" );

Please take a look at your suggested code. I do believe that your second suggestion is what I have.

thanks for your quick reply.

kd

Replies are listed 'Best First'.
Re^3: defined or undef
by ikegami (Patriarch) on Oct 30, 2007 at 15:20 UTC

    Undefined is a special *scalar* value. It makes no sense to call an array undefined, so that should read
    print ( @rtnVal ? " not empty \n" : " empty \n" );

    Whether getElementsByTagName returns an list or not is irrelevant. I was asking what did you want getCBLValue to return.

      as you suggested I have been using
      print ( @rtnVal ? " not empty \n" : " empty \n" );
      in many places.

      I expect getCBLValue to return a list.

      Maybe I should declare @rtnVal as follows:
      my @rtnVal ;
      And see what happens.

      kd
        yes if I just declare @rtnVal as follows:
        my @rtnVal;
        It works. Must check the rest of my code for this mistake.

        many thanks for your assistance

        kd