http://qs1969.pair.com?node_id=46197


in reply to Finding Previous and Next in a HASH

I forget where I read it - whether it was on this site or in a Perl book - but someone said/wrote that if you find yourself wishing arrays were associative or hashes were ordered, you're using the wrong tool.

It seems to me that you sould start off with an array and not use a hash at all.



FouRPlaY
Learning Perl or Going To die() Trying

Replies are listed 'Best First'.
Re: Re: Finding Previous and Next in a HASH
by myocom (Deacon) on Dec 12, 2000 at 05:17 UTC

    Sometimes you end up with conflicting wishes, though. For the problem I was having earlier, I had a case of requiring unique keys and also wanting to index into the hash (or rather, the keys of the hash). In my case, at least, the fact that hash keys are by definition unique outweighed my desire for ordered hashes. Otherwise, you're right, I would've used an array. :-)