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
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.print Dumper(@bin);
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |