One way to the answer to your question is the keys function in conjunction with sort ... you can call my @keys = sort keys %hash; to get a sorted array of the keys of the hash; while you're poking through the hash, set an index variable and grab $keys[$index-1] and $keys[$index+1] to get the keys you want.
(Of course, you should add in some checks to determine when you're at the beginning and at the end of the list of keys!).
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In reply to Re: Finding Previous and Next in a HASH
by arturo
in thread Finding Previous and Next in a HASH
by skazat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |