in reply to using undef on a array

My humble understanding is:
  1. Here you create the array, then set all it's values to nothing, therefore the array is defined, but has no content
  2. In this case you undefine the array, so it's not defined any more and also has no content. It still exists, so you can still use it without error.
  3. As other have said here you're simply setting the first value of the array to an undef value.

Interesting question.

Replies are listed 'Best First'.
Re: Re: using undef on a array
by Anarion (Hermit) on Oct 31, 2001 at 15:00 UTC
    The last one is easy to understand, but if i try to asing a undef value to $#a it is not modified:

    perl -le 'use strict;my @a=("a");$#a=undef;print "Defined" if defined @a;print @a'
    Defined
    a

    But whats the meaning of defined, what exactly do the undef @a,what exatly perl do? If i write $#a=-1 i'm clearing all and have no values, the both, 1 and 2 have no content, thats why it prints that they have 0 elements, buf one its undefined, but still avaliable, sorry if i dont understand what it means with defined, you say it still exists ... in both cases exists and are emptys.

    $anarion=\$anarion;

    s==q^QBY_^=,$_^=$[x7,print