in reply to Calculate comparison between

Just another way perhaps simpler (untested):

my $max_inf = $first_beg > $second_beg ? $first_beg : $second_beg; my $min_sup = $first_end < $second_end ? $first_end : $second_end; if ($min_sup - max_inf >= 5) { #...

Update Jul 27, 2013 at approx. 22:20 UTC: I must admit that when I posted this, I had not seen (or not read carefully enough) the proposal made by zwon, but I had only read his comment on wrong boolean test. Looking back to my post and zwon's post, I must say that my proposal is essentially using the same idea and does not bring very much more, except that it does not use a module. I do not regret having posted my solution, but I regret not having seen and therefore not having said upfront that my solution was in fact a variation on the solution posted by zwon.