"You need references. Everybody programming in Perl does, since
they are one of the basics of the language. A bit like C's
pointers, references can be used to refer to all sorts of other
things, including scalars, arrays, hashes, filehandles, typeglobs,
subroutines, and synthetic data structures. If C calculates
addresses and dereferences pointers with & and *, respectively,
Perl does much the same with \ and $."
"Why use references? First, they go great with subroutine
calls. The usual way to pass an array or hash between a
subroutine and its caller involves pushing around all the values of
the array or hash. You can get the same or better results instead
by passing just the single reference to the array or hash."
"Also, references are necessary for complex data structures. The
values of arrays and hashes must be scalars, so there's no direct
way to make hashes of hashes. However, references have the syntax
of scalars, so you can make arrays of references to arrays
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.