in reply to looping through an array reference of hash reference

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."