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.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}; }
"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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |