Hi, I want to compare two files on the basis of two different Ids, and want to print something, if the Ids matched.

I opened the two files and used while loop (i.e. while within while). The if condition of this prog. is working good, but else condition will give lots of lines, because of while within while.. "last;" is also not working here..

Please help me to solve this

file 1

chr17 69112551 chr7 151046672 chr7 151047369
file 2
chr1 66953622 66953654 chr1 67200451 67200472 chr1 67200475 67200478 chr1 67058869 67058880 chr1 67058881 67058885 chr1 67058887 67058895

Perl prog.

#!/usr/bin/perl -w $pwd = `pwd`; chomp($pwd); $file=$ARGV[0]; $file1=$ARGV[1]; open(IN,$file); while ($line=<IN>){ chomp($line); @ary = split(/\t/,$line); chomp($ary[0]);chomp($ary[1]); open(SK,$file1); while($line1=<SK>) { @any = split(/\t/,$line1); chomp($any[0]); chomp($any[0]);chomp($any[1]);chomp($any[2]); if ($ary[0] eq $any[0] and $ary[1] == $any[1]) or ($ary[0] eq $any[0] +and $ary[1] == $any[2]) { print "$line\tE\n"; } else { print "$line\tM\n"; } } }

In reply to compare two files on the basis of Two IDs by genome

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.