in reply to duplicates getting omitted while comparing values inside foreach.
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: duplicates getting omitted while comparing values inside foreach.
by patric (Acolyte) on Apr 16, 2009 at 09:36 UTC | |
|
Re^2: duplicates getting omitted while comparing values inside foreach.
by patric (Acolyte) on Apr 16, 2009 at 09:20 UTC |