laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Assuming you know the first key, you have a few simple options. The first first is to pull the keys from the nested hash and do a search through them.
You can then use $max_event to determine what your next event should be. If you have to do this many times, I would suggest an additional field in your hash that tracks the max event like so:
Now if you need to know the current highest event, you just examine $hash{1}{current_max}. You'll have to ensure that you increment this field each time you add an event. This approach could be a problem if the event could have a valid data field named current_max. In this case, you will have to modify your data structure to ensure that the current_max field is cleanly separated from the event data. But it would otherwise work the same. In reply to Re: Determine largest key in hash
by tj_thompson
|
|