in reply to Array of variables
Indeed, if there is but one fragment of Perl-voodoo that you need to read about right away, it would be: references. (See: perldoc perlref, perldoc perlreftut, and their many brethren.)
The essential idea is a disarmingly simple one: a “reference” is “a single, scalar thing” (so it qualifies to be the value of a variable, or an element in an array or in a hash ...) which can “refer to” anything-at-all. Perl takes care of all the messy memory-allocation, reference-counting and garbage-collection headaches for you, and for the most part, it is also quite prescient when it comes to understanding the code that you’ve written. (Perl was written by people who need to get work done, not by computer academics.)
You can pretty much build “arrays of hashes of hashes of arrays of ...” with impunity, because you actually build “arrays of references to hashes of references to hashes of references to arrays of ...” (This is also where the Perl slang terms, “arrayref” (== reference to array) and “hashref” (== reference to hash) come from.)
The Perl language also allows you several different ways to write the same thing ... the choice being up to you. Unlike most other languages, Perl does not impose “the designer’s one-and-only opinion as to what is ‘the right way to do it’ ” upon you. This philosophy gives rise to TMTOWTDI == “Tim Toady” == There’s More Than One Way To Do It.™”
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array of variables
by chromatic (Archbishop) on May 28, 2013 at 21:40 UTC | |
by Grimy (Pilgrim) on May 28, 2013 at 23:44 UTC | |
by chromatic (Archbishop) on May 28, 2013 at 23:56 UTC | |
by BrowserUk (Patriarch) on May 29, 2013 at 01:27 UTC | |
by chromatic (Archbishop) on May 29, 2013 at 01:48 UTC | |
|