Linux Magazine: Getting Better References Through PerlMay 20, 2000, 20:07 (1 Talkback[s])
(Other stories by Randal L. Schwartz)
"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 of...."
0 Talkback[s] (click to add your comment)