good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Fun with arrays and hashesby moodster (Hermit) |
on Apr 16, 2002 at 15:23 UTC ( [id://159524]=note: print w/replies, xml ) | Need Help?? |
1. I haven't meddled with dbmopen or tiehash, but you could always check out the Tie::Array module. Or go with Storable, which is included in the standard distribution and will store anything.
2 & 3. A hash is not ordered, so there is no way to access the 'first' element. However, the keys( %hash ) function returns an array of the keys of a hash. This array is not ordered and calling keys repeatedly may or may not yield the same results. A common construct is to sort the keys before looping over the array; this will step through the hash in the alpabetical order of the keys, which is nearly but not really the same thing you are asking for in 2)
Cheers,
In Section
Seekers of Perl Wisdom
|
|