in reply to defined or undef

defined is not meant to be used on arrays and must not be used on arrays in forward-compatible code. It doesn't do anything meaningful.

There's some uncertainty as to what you are trying to do.

Update: Added second bullet.

Replies are listed 'Best First'.
Re^2: defined or undef
by Fletch (Bishop) on Oct 30, 2007 at 14:57 UTC
Re^2: defined or undef
by kevind0718 (Scribe) on Oct 30, 2007 at 15:18 UTC
    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

      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