[prev] [index] [next]

Arrays (Lists)

An array is a sequence of scalars, indexed by position (0,1,2,...)

The whole array is denoted by   @array

Individual array elements are denoted by   $array[index]

$#array gives the index of the last element.

Example:

$a[0] = "first string";
$a[1] = "2nd string";
$a[2] = 123;
or, equivalently,
@a = ("first string", "2nd string", 123);

print "Index of last element is $#a\n";
print "Number of elements is ", $#a+1, "\n";