Here is somewhat simplified, but untested code , in an attempt to steer you toward more idiomatic code:
my @officialannotation = (); # An empty list. NOT [] , which is an emp +ty array-ref my $offgenes; open(my $infile , "<", "genbankfile.txt") or die "cannot open file gen +bankfile.txt $!"; while(<$infile>) { $offgenes++ if ($_ =~ /\d+/) ; my ($start, $stop) = split; push @officialannotation, {start=> $start, stop => $stop}; } close $infile; #.. collect the other one in the same way # Then compare the 2 arrays of hashrefs : for my $p (@prodigalannotation){ next unless my ($candidate) = grep {$p->{start} eq $_->{start}} @of +ficialannotation; $exactmatching++ if $candidate->{stop} eq $p->{stop}; }
Note - there are many assumptions of the data, and no error checking, and inefficiencies, so this code is far from ideal, but I offer it as an incremental improvement on the OP.

            "XML is like violence: if it doesn't solve your problem, use more."


In reply to Re: looping through an array reference of hash reference by NetWallah
in thread looping through an array reference of hash reference by PrincePerl

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.