First, $a and $b are special variables, and you shouldn't ever name your variables with those names. Never ever.

Second, this line has a couple of problems:

for my $b ( 0 .. $#{$array_of_lists->{$b}} )

You're using $b on the same line where it's declared with my, and you're using $array_of_lists as a hash reference, when you mean to use the %array_of_lists hash. I think what you mean is "$#{ $array_of_lists{$a} }" but again, rename $a and $b. Even at that, your %array_of_lists keys start at 1, so you really want this:

for my $b ( 1 .. scalar @{$array_of_lists{$a}} )

There are other places you're misusing %array_of_lists, but I won't mention them all. This should get you on the right track.

You might also want to look at perlreftut, perlref, and References quick reference.


In reply to Re: working with hashes of arrays by kyle
in thread working with hashes of arrays by gman1983

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.