Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone!
I have 2 text files with some number ranges, e.g.:
100000313-100001222
in one file and 100000391-100000947 in the other.
My goal is to take each line from each file and see if it is somehow "contained" in the other. As you can see from the example, the range 100000391-100000947 is within the range 100000313-100001222.
Can you provide me with some help as to how I can deal with such a problem?
Is there some module or something?
Thank you very much for your time!

Replies are listed 'Best First'.
Re: comparing ranges of numbers between 2 files
by haukex (Archbishop) on Oct 15, 2017 at 10:34 UTC
Re: comparing ranges of numbers between 2 files
by LanX (Saint) on Oct 15, 2017 at 11:15 UTC
    Since you only need to see if it's contained it's simply checking $a1 < $b1 and $a2 > $b2 for each combination of lines from file A and B.

    you can use my ($a1, $a2) = split '-', $line to split the ranges.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!