Hi rambosauce and welcome to the monastery.

I'm a perl novice
I wouldn't have guessed that, your code is quite well written.

To answer your question, here is something you can do:

my %transcripts; { open(my $transcripts_fh, "<", $transcripts_qfn) or die("Can't open \"$transcripts_qfn\": $!\n"); while (<$transcripts_fh>) { chomp; my @refs = split(/\t/, $_); my ($ref_chr, $ref_strand) = @refs[0, 6]; $transcripts{$ref_chr}{$ref_strand} = {start => $refs[3], end => + $refs[4], info => $refs[8]}; } }
(Edit: untested for lack of input data)
Now when you are reading the second file, rather than going through all transcripts, you can directly obtain
my $transcript = $transcripts{$chr}{$strand}; my $start = $transcript->{start}; my $end = $transcript->{end}; my $info = $transcript->{info};
That's assuming that $ref_chr and $ref_strand are a unique pair. If you can have several start/end/info values for a given chr-strand pair, you'll have to use an intermediate array (I didn't want to give the more complex solution if the simple one is enough).

FYI, for debugging you can easer have something like:

use Data::Dump "pp"; ... say pp \%transcripts; # debug the content of %transcripts
or
use Data::Dumper; ... say Dumper \%transcripts;
The first looks nicer, but Data::Dumper doesn't require an installation.


In reply to Re: How to make a hash to evaluate columns between large datasets by Eily
in thread How to make a hash to evaluate columns between large datasets by rambosauce

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.