http://www.perlmonks.org?node_id=1036782


in reply to Re^2: scoping problems
in thread scoping problems

Further to hdb's reply:

... it seems that a shorthand like [evaluating an array in scalar context] cant travel well around different loops etc.?

It travels perfectly well. hdb and others have already pointed out that  @saba and  $saba are quite different things and are in no way inherently related.

What may be confusing you is the fact that an element of the  @array array is accessed by the syntax  $array[n] (note the  $ sigil). The logic of this, determined by Larry at the Dawn of Time (Perl version 1.0), is that the elements of arrays (and also of hashes – associative arrays) are always and only scalars. But you always have to distinguish between an array, which contains (like a hash) a certain number of elements and thus has, among other properties, a size, and an element of an array.