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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.