in reply to Hash keyed on ranges

Sounds like you want an array of end-of-range values to binary search, and then a hash keyed on the end-of-range value found. (I suggest using the end-of-range value because your values are contiguous for 0..n; if the binary search fails you know you are higher than n without having to maintain/check it separately. Negative input should obviously also be checked for.)