Table of Contents

Lists, herds -- what are arrays?

Perl has two types of array, associative arrays (hashes) and arrays. Both types are lists. A list is just a collection of variables referred to as the collection, not as individual elements.

You can think of Perl's lists as a herd of animals. List context refers to the entire herd, scalar context refers to a single element. A list is a herd of variables. The variables don't have to be all of the same type -- you might have a herd of ten sheep, three lions and two wolves. It would probably be just three lions and one wolf before long, but bear with me. In the same way, you might have a Perl list of three scalar variables, two array elements and ten hash elements.

Certain types of lists are known by certain names. Just as a herd of sheep is called a flock, a herd of lions is called a pride, a herd of wolves is called a pack and a herd of managers a confusion, some types of Perl list have a special names.