my @officialannotation = []; my @prodigalannotation = [];

Why are you assigning an array reference to $officialannotation[0] and $prodigalannotation[0]?



%findgene = ( "start" => $offcordinates[1], "stop" => $offcordinates +[0] ); $hash_ref = \%findgene;

Or just:

$hash_ref = { "start" => $offcordinates[1], "stop" => $offcordinates[ +0] };


@officialannotation = []; push @officialannotation, $hash_ref;

You are removing all previous elements of @officialannotation with the assignment, and you could just write that as:

@officialannotation = ( [], $hash_ref );

But why do you need the array reference as the first element?    And because both %findgene and $hash_ref are at file scope the hash reference will always point to the same variable.



for $hash_ref ( @$officialannotation ) { while (my $start, $stop) = each %$hash_ref ) { for $hash_ref2 ( @$prodigalannotation) { while (my $start1, $stop2) = each %$hash_ref2 ) {

Because the first element of @officialannotation and @prodigalannotation are ARRAY references instead of HASH references you should be getting error messages here.




In reply to Re: looping through an array reference of hash reference by jwkrahn
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.