Would I have to write that as:
foreach my $index ( 0 .. $#matches{$fastaseq}{$sitekey} )?

You would have to write that as:

foreach my $index ( 0 .. $#{$matches{$fastaseg}{$sitekey}} )
Note the extra braces following "$#" and fully surrounding the  $matches{$fastaseg}{$sitekey} -- that latter bit constitutes an array reference, and perl won't be able to parse it as such next to "$#" unles the braces are there to establish the precedence for de-referencing the array ref that is the value of that hash element.

As for undefined elements, I don't expect I'll see any.

Yeah, we've all heard that before... (and we've all caught ourselves saying and believing the same thing, in reference to some chunk of code we've written). That's the best thing about making good use of a good debugger: it helps us to get past this kind of fantasy.

In reply to Re^3: foreach in HoHoA problems by graff
in thread foreach in HoHoA problems by mdunnbass

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.