in reply to Difference between array and a hash? (Newbie concerns)
Basically every "array" in PHP is an array and a hash, glued together. All of the values are stored in the hash as key/value pairs, but there's an array stored along with it that gives an ordering to the keys. The thing is, most of the time you either need one behavior (in-order processing) or the other (random lookup), and not both. PHP is giving you the overhead of both at all times; Perl is requiring you to say which one you really want. In the case where you really do need both methods, it's not very hard to set up the necessary parallel data structure in your own code, but Tie::IxHash is another option.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Difference between array and a hash? (Newbie concerns)
by Anonymous Monk on Jul 30, 2009 at 03:28 UTC | |
by hobbs (Monk) on Jul 31, 2009 at 09:30 UTC | |
by Anonymous Monk on Jul 31, 2009 at 09:33 UTC | |
by hobbs (Monk) on Jul 31, 2009 at 09:56 UTC |
In Section
Seekers of Perl Wisdom