WHAT YOU WILL LEARN IN THIS CHAPTER:
- Creating and understanding array, hash, anonymous, and other references
- Manipulating references
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at http://www.wrox.com/WileyCDA/WroxTitle/Beginning-Perl.productCd-1118013847,descCd-DOWNLOAD.html on the Download Code tab. The code for this chapter is divided into the following major examples:
In Perl, you tend to care more about how you organize your data than the kinds of data you have. As a result, Perl enables rich, complex data structures and imposes few limits on how you can organize your data. When you get used to the syntax, you may be pleasantly surprised. Memory management is handled for you; there is no pointer math to get wrong; and there are no external libraries to choose from and load. You just use the references.
In some languages, complex data structures are built up via pointers (something that “points” to a variable’s location in memory) stored in other data structures, with perhaps pointers to those data structures, in turn, stored in other data structures. Then you can have fun with pointer math, memory management, and obscure compiler errors.
Some languages, on the other hand, offer a bewildering array of different classes to implement a variety of different data structures, depending on what you need and how much time you ...