3.1 Arrays or Lists

A list is a multi-component data structure where the position of an element in the structure matters. That is, the idea of what is before a certain element and what is after a certain element is paramount. A list is a variable length data structure. An array is usually a fixed length data structure which is simpler than a list, and where elements can be accessed using numeric indices. Perl implements the list data structure using an array. The distinction between the two data structures is briefly discussed in SectionÊ1.7. For a more detailed discussion, the reader is referred to a text book on data structures such as [TC03].

We will use the two terms, array and list, interchangeably although it is not strictly correct. An element in a list or an array must be a scalar and is identified by its position. The name of an array variable in Perl starts with the symbol @. Therefore, @friends, @aList, @myArray100, and @name_array are valid names of arrays. _friends, friends, or %friends are not valid array names in Perl.

In Perl, an array can be only single dimensional although multi-dimensional structures can be simulated. Since an array, strictly speaking, is single-dimensional, the term array is actually somewhat of a misnomer. What we have here is a vector although we will continue using the term array due to tradition.