Given two ranges, do the following: 1) check if the start or the end of each range deviate by more than five 2) check if the intersection of the range is at least half its union #### use Set::IntSpan; $range1 = Set::IntSpan->new([45 .. 60]); $range2 = Set::IntSpan->new([49 .. 57]); $intersect_range = $range1->intersect($range2); $union_range = $range1->union($range2); print "INTERSECT:".$intersect_range."\nUNION:".$union_range."\n"; $diff_between_starts = abs($range1->min-$range2->min); $diff_between_ends = abs($range1->max-$range2->max); print "START DIFF:$diff_between_starts\n"; print "END DIFF:$diff_between_ends\n"; if($diff_between_starts<=5 && $diff_between_ends<=5) {print "ALL IS OK\n";} else {print "PROBLEM\n";}