in reply to Finding Previous and Next in a HASH
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Optimized Previous and Next Accessors
by tedv (Pilgrim) on Dec 12, 2000 at 08:26 UTC | |
|
Re: Re: Finding Previous and Next in a HASH
by myocom (Deacon) on Dec 12, 2000 at 04:59 UTC |