in reply to Re^2: if (defined @arr) problem
in thread if (defined @arr) problem

> Still, testing definedness of an array is a very bad idea.
> Try running this code first: 
>
> @a = qw(a b c);
>
> and now you'll see, the array will be defined (and empty).

Hmm, i get "defined: yes" and "size: 3" ...

@a = qw/a b c/; printf "defined: %s\nsize: %d\n" , defined @a ? 'yes' : 'no' , scalar @a ;

... what did i miss?

Replies are listed 'Best First'.
Re^4: if (defined @arr) problem
by bart (Canon) on Dec 15, 2005 at 17:40 UTC
    You missed plugging it into the whole script. I said "do this first", didn't I?

    Well, apparently that wasn't clear, so here is the whole current script, as I see it.

    #! /usr/bin/perl @a = qw/a b c/; @a = test(); printf "defined: %s\nsize: %d\n" , defined @a ? 'yes' : 'no' , scalar +@a ; sub test { return () ; }
      Yes, you certainly mentioned "do(ing) it first". I was not sure what or where exactly you meant for the behaviour shown (in the complete program given above) is what /i/ already expect. Thanks for the clarification.