The pairing is true if the difference between end of one string and start value of the other string is greater than 300.

Just turn your words into code :)

#!/usr/bin/perl use strict; use warnings; my @data; while (<DATA>) { push @data, [ $_, (split ' ')[2,3] ]; # [ input-line, start, end +] } my $cnt; for my $d1 (@data) { for my $d2 (@data) { my $dist = $d1->[1] - $d2->[2]; # start of one - end of the + other if ($dist > 300) { print "Pair", ++$cnt, ":\n"; print " ", $d2->[0]; print " ", $d1->[0]; print "Distance: $dist\n"; } } } __DATA__ ACNGYNDHNG 10 1333 1343 1152 AVDVHVHNGG 10 209 219 2916 ACNGYNDHNGARRT 14 1333 1347 4608 GNDNNVNNRHNNNNVMNNVNNT 22 1589 1611 6291456

Output:

Pair1: AVDVHVHNGG 10 209 219 2916 ACNGYNDHNG 10 1333 1343 1152 Distance: 1114 Pair2: AVDVHVHNGG 10 209 219 2916 ACNGYNDHNGARRT 14 1333 1347 4608 Distance: 1114 Pair3: AVDVHVHNGG 10 209 219 2916 GNDNNVNNRHNNNNVMNNVNNT 22 1589 1611 6291456 Distance: 1370

In reply to Re: how to pair strings based on positional differences by almut
in thread how to pair strings based on positional differences by BhariD

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.