Btree (or lack thereof) isn't the reason for this bug. The bug is in the placement of your print OUT statements. If you clean up the indenting you will notice that lines only print out if

On the rows where it fails to print out, I presume that $variant is defined, but either the left or right flag is something other than 1.

To fix this I recommend that you move the code for calculating the final column into a separate sub that returns either the file name or "-". Then your loop to read in file 2 should (pseudo code) look something like this:

while (my $line = <DATA>) { my @aFields=split(/\s+/,$line); my $kDb= $aFields[0] . '#' . $aFields[1]; my ($variant,$rs) = split('##', $hash1{$kDb}); #code to calculate my $result=calcFinalColumnValue($variant,$rs,\@aFields); #print row print "@aFields $result\n"; }

Also, you might want to consider two changes to make this code more efficient.

Best, beth


In reply to Re: duplicates getting omitted while comparing values inside foreach. by ELISHEVA
in thread duplicates getting omitted while comparing values inside foreach. by patric

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.