Hi Monks,

I have started to learn perl but now I am completely stuck in this problem, thus I seek your help.

I have seven files with different number ranges. I want to compare their ranges and detect the common range from them. Below I have shown an example with three files (file1.txt, file2.txt anf file3.txt). These files are like:

file1.txt:

68476204: 9-50, 55-75, 80-132 NC_23987: 2-22, 1001-1085 68473073: 1-8 68485121: 1-10, 20-55

file2.txt:

68485121: 15-45 45905121: 2-98, 201-255 68476204: 8-30, 57-77, 88-180 NC_23987: 1-18, 1021-1055 68473073: 14-44

file3.txt:

68485121: 16-42 68476204: 8-22, 55-76, 81-118

From here, I want to generate two output. First one is the common ranges (common in all three) after matching left column value(which are common in all three of them). For the above input, my output1.txt will be:

68485121: 20-42 68476204: 9-22, 57-75, 88-118

The second output (output2.txt) contain only those ranges those are >=15. Here, the output2.txt will be:

68485121: 20-42 68476204: 57-75, 88-118

Any type of suggestion is appreciated.

Thanks


In reply to Intermediate range calculation from files by abhikalrt53

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.