in reply to compare values within a hash
So, you are trying to merge "overlapped" ranges except that you have a fixed size extension around each range? If that is what you are after then probably the easiest way to manage the problem is to build an array sorted by range start. Probably makes things easier if you subtract half the overlap value from the low value of each range and add half the overlap to the high value - that is, store the extended range in each case.
Once you have build your data structure (a hash of groups where each group entry is an array of ranges), you can run through each range array and amalgamate adjacent ranges in the array that overlap. Because the ranges have already been extended the logic for that should be fairly straight forward. When you are done with amalgamating ranges you can run through the result and adjust each range end point by removing the extension value.
|
|---|