Recipes for Structures

The following sections present some of the more common arrangements of lists and hashes into structures.

Example: A List of Lists

Lists of lists in Perl are often used to represent a common structure called a two-dimensional array. That is, a normal array is a linear list of values, as illustrated here:

A two-dimensional array is like a grid of values in which each element is addressed like a point with coordinates along two axes. The first part of the index indicates a row number (starting with 0), and the second is the column, as you can see here:

Perl doesn't really support a true two-dimensional array. However, Perl ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.