page 1  (12 pages)
2to next section

Expanding the text here will generate a large amount of data for your browser to display

The Perl Data Structures Cookbook

by Tom Christiansen

< tchrist@perl.com >

release 0.1 (untested, may have typos)

Sunday, 1 October 1995

This is a cookbook of recipes for building up complex data structures in perl5. It has been extracted

from a much larger and more expository document to be published in pod format and included with the

standard perl distribution. The goal is to provide cookbook-like, cut-and-paste examples of the most

often used data structures in perl. Think of the recipes as a quick reference

It currently has 6 parts:

PDSC General Tips

PDSC recipes: Lists of Lists

PDSC recipes: Hashes of Lists

PDSC recipes: Lists of Hashes

PDSC recipes: Hashes of Hashes

PDSC recipes: More Elaborate Structures

See also:

Tom Christiansen's homepage at http://perl.com/.

The Perl FAQ.

PDSC #0: General tips

The first thing you need to do is figure out how you want to access (such as via an assignment) just one

individual element of your data structure just using lists and hashes. Use a list if you're thinking of an

array, use a hash if you're thinking of a record or a lookup table.

$coordinates[$row][$col] = "empty"

This is a simple two-dimensionsal array indexed by integers. Each first level numeric index itself

produces a list (reference). See the List of Lists document.

$flight_time{"denver"}[3] = "12:34"

This is an (associative) array of lists. Each first level string index itself produces a list (reference).

See the Hash of Lists document.