XP is just a number | |
PerlMonks |
Finding Previous and Next in a HASHby skazat (Chaplain) |
on Dec 12, 2000 at 04:06 UTC ( [id://46185]=perlquestion: print w/replies, xml ) | Need Help?? |
skazat has asked for the wisdom of the Perl Monks concerning the following question: Hello everyone, I have a hash, that could look like this: I want to be working on the value of key number five, but I'll need the value of the previous and next keys (when sorted in numnerical order), in other words, if I'm working on $hash{2} I need the value of $hash{1} and $hash{4} This seems really tricky to me, especially when the key values skip numbers and/or you're at the end of the sorted hash, like $hash{24} and $hash{1}. It makes sense that I should first sort the keys in numeric order using an array to hold the keys but after that I'm stumped, all my loops aren't working, Anyone want to help?
-justin simoni
Back to
Seekers of Perl Wisdom
|
|