On 6/25/07, sivasakthi <[EMAIL PROTECTED]> wrote:

What is order of retrieving the values from Hash??

Hash data items are retrieved in the "natural" order in which they're
stored in the hash. It's hard to say what that order is, but we know
what it's not. It's not alphabetical order, and it's not the order
that elements were stored into the hash. It's not random order, which
might be nice, and it's not sorted by value, as convenient as that
would be. It's not an order that is sure to be the same for every
release of Perl, for every implementation of Perl, or even every time
you run your program with the same perl binary on the same OS on the
same day. It's not any order that's useful for anybody but Perl, in
fact, so we may as well say it's in no order at all. But it is in
_some_ order; keys(), values(), and each() all use the same,
repeatable, order (at least, until you add new items to the hash).

If you need any particular order, of course, that's easy to get. You
can either sort items directly into the order you want, or you could
use a module that keeps a hash in order for you.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to