Dear monks,

I have some paired values which i've mapped into a hash.

The data looks something like this (one is the key, the other is the value):

my %hash = map {$gp1[$_] => $gp2[$_]} 0 .. $#gp1; #13488050:c183911-182727 57165207:6809301-6810488
I also have a large space-delimited table with keys and values as above in the first and second columns. I want to find all lines that match each key-value pairs as the first and second values in each row ($1 and $2 in the loop below) and print them with the rest of the data in each line.

I have a loop going though the table below, but am not sure how to check if $1 and $2 are equal to a key-value pair in the hash. Hope someone can help!

foreach my $line (@blast) { if ($line =~ /gi\|(\d+.{1,2}\d+\-.{0,1}\d+)\s+gi\|(\d+.{1,2}\d ++\-.{0,1}\d+)\s+(\d{0,2}.{0,2}\d{0,2}.{0,2}\d{0,3})\s+\d+\s+(\d+.{0,3 +}\d+)\s+\d+\s+\d+\s+\d+\/\d+\s+(\d+)/) { ###print "$1\t$2\t$5\n"; my $n1 = $1; push @id1, "$1 "; push @id2, "$2 "; push @percent_id, "$5 "; # need to here check whether $1 eq key and $2 eq value + but am stuck! } }

In reply to hash confusion 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.