Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Calculate the overlap length between two ranges

by poolpi (Hermit)
on Oct 30, 2013 at 12:17 UTC ( [id://1060352]=note: print w/replies, xml ) Need Help??


in reply to Calculate the overlap length between two ranges

Please have a look at this module Set::IntSpan.

#!/usr/bin/perl use strict; use warnings; use Set::IntSpan; my $set1 = new Set::IntSpan '31-52'; my $set2 = new Set::IntSpan '27-50'; my $u_set = intersect $set1 $set2; my @set = sets $u_set; print @set; __END__ output: 31-50

Update: code + typo


hth,
PooLpi

The stone that the builder refused, will always be the head cornerstone.
[ Robert Nesta MARLEY ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1060352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found