As others point out quite well, $foo[$bar][$baz] is a List of Lists (array of arrays), which is basically the same thing as a multi-dimensional array in other languages.

An additional point is that you aren't seeing hundreds of lines of output because many of the values in your data structure are undef, and undefined values are not printed. If you use warnings; the print statements acting on undefined values will notify you with "Use of undefined value in print or join".

To see what the data structure looks like, use the module Data::Dumper::Simple and use

print Dumper(@bin);
to examine the structure of @bin. This will produce rather verbose output, so you may wish to redirect it to a file. Since the output is a Perl data structure, viewing it as a Perl file in a syntax-highlighting editor is most helpful.

Instead of using an array, you may wish to use an "associative array", or hash, which uses strings rather than sequential numbers as keys. Of course, all numbers can be expressed as strings trivially, so little would need to change in your code. Hashes are only minutely slower than arrays (you won't notice unless you're processing huge amounts of data) -- but the reduction in memory you will experience in not having to have a 100-element array to store 4 results will likely make up for this anyhow.

Anima Legato
.oO all things connect through the motion of the mind


In reply to Re: Counting frequency of occurrence - what am I doing? by legato
in thread Counting frequency of occurrence - what am I doing? by Annemarie

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.