Or maybe get some inspiration from Set::IntSpan
In reply to Re: Calculate the overlap length between two ranges by toolic in thread Calculate the overlap length between two ranges by Anonymous Monk