There's more than one way to do things | |
PerlMonks |
Re: Re (tilly) 1: Hash Tutorialby jreades (Friar) |
on Jun 22, 2001 at 18:28 UTC ( [id://90731]=note: print w/replies, xml ) | Need Help?? |
The fundamental key IMHO is this. As long as you are doing a lot of thinking involving positional logic, you are not being very Perlish. I just wanted to qualify this statement with a slightly tangential one of my own -- as a newbie, when you discover the power of hashes in Perl they become intoxicating. Oh, this could be a hash. Oh, and so can this. And this. And this. And... tilly's very erudite description of the hash glosses over this slightly, but only because, as a saint, he's probably forgotten how we men and women in the trenches think. It is important to remember that hashes have higher overhead and are slower to access than an array, but, in contrast, accessing a hash is essentially a constant time operation -- meaning, that as long as I know what item I want, it takes the same amount of time to access the 1st element of the hash as the nth. There is a lot of overlap between arrays and hashes conceptually in Perl (and even more so under the hood), and you need to keep in mind how you are intending to use your data structure and the kind of data it will hold. For instance, a few general examples:
The rules/ideas go on for many lines from there, but I guess what I'm getting at, is that Perl makes it possible to see the world through hash-tinted glasses <pun intended>, but always keep in mind that the lowly array is an equally adept tool for many jobs.
In Section
Seekers of Perl Wisdom
|
|