Hello Monks!
So, it seems like a very trivial problem for me, but my code so far is not working properly.
What I want to do is, supposedly you have two numerical ranges, like:
117-137 AND 112-130

and you want to check whether the second one has an overlap of at least 5 positions with the first one (at least 5 positions must be included in the first one).
How do you proceed? I tried:
$flag_correct=0; if( ($second_beg>=($first_beg-5)) && ($first_beg<=($second_beg+5)) && +($first_end>=($second_end-5)) && ($first_end<=($second_end+5)) ) {$fl +ag_correct = 1;}

but this doesn't work correctly, because in the case mentioned above the flag remains 0.

In reply to Calculate comparison between by Anonymous Monk

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.