Reprieve
February 7, 2000
Which is more difficult, the abstract concepts behind Perl
structures-within-structures or the syntaxes needed to
represent them? Both can be a chore to get under your belt.
The good news is that abstract concepts are, as they say,
like riding a bike -- you don't forget them once they're
locked in. But unless you code lists and hashes in Perl
with some frequency, it may be more challenging to
remember the syntax, especially with regards to nesting
parentheses and square and curly brackets and the usage
and placement of the $ (scalar), @ (list), and % (hash)
prefixes.
Hopefully, the examples in this article can serve as syntax
refreshers down the road, when you're stuck in the middle of
a complex program and wondering "how do I add a key to
a hash within a list?", just before you jump
out the window.
Resources
The
Perl You Need to Know: Lists
The
Perl You Need to Know: Hashes
Perl
Data Structures Cookbook
Manipulating
Lists of Lists in Perl
A Hash of Hashes
The Perl You Need to Know
|