I am trying to match an array with the related value in the hash. Hash and array are opened and print fine but I can only get the match for one line not the complete array. Please help, I'm completely stuck and I keep hitting the same problem no matter how I write the rest.

my $Start_rank; my @b; my $line2; my %hash; my $Rank; my $info; while (<INFILE>) { my $line=$_; $line=~s/\s$//; chomp($line); my @a; #my @a=split/\t/,$line; ($Rank, my $id, my $C, my $Position) = split /\t/, $line; next unless $Rank=~/\d+/; $info = $id . "\t" . $C . "\t" . $Position; $hash{$Rank}= $info; } while (<INFILE2>) { $line2=$_; $line2=~s/\s$//; chomp($line2); my @b=split/\t/,$line2; next unless $b[0]=~/\d+/; $Start_rank = $b[1]; while (($Rank, $SNP_info) = each (%hash)) { foreach ($line2) { if ($Start_rank eq $Rank ) { print "$Start_rank\t$info\t$b[2]\t$b[3]\t$b[4]\t$b[5]\t$b[6]\t$b[7]\t$ +b[8]\t$b[9]\n"; } else {print "no match\n"; } } }}

I should get ~60 matches, instead I get one. Thank you for anything you can suggest.


In reply to match loop failure 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.