in reply to Existing items

Just as with hashes, there's a clear distinction between whether an array element exists and whether it's defined. It can exist, but be undefined, as the following code illustrates:
$exp[12] = undef; printf "%d,%d,%d,%d\n", exists $exp[11], exists $exp[12], exists $exp[ +13], scalar @exp; printf "%d,%d,%d,%d\n", defined $exp[11], defined $exp[12], defined $e +xp[13], scalar @exp;
This prints:
0,1,0,13 0,0,0,13
This code illustrates a several things:
  1. Even if an element is undefined, it can still exist.
  2. Setting an element to undef brings it into existence, but checking whether it's defined does not.
  3. Just because an array element n exists, doesn't mean that all prior elements (0 .. n-1) also exist. If the array is sparsely populated, Perl keeps track of that fact.
  4. The size of an array, given by the scalar function, is not the number of elements that exist, but rather one plus the highest index of those existing elements.
So to answer your question, if you're really interested in whether an array element exists, use the exists function, not defined.