in reply to confusing question, involving multidemensional arrays

It sounds like what you want is a hash of arrays. You'd set it up something like:
my $cat = { birds => [], turds => [], flirds => [], };
Then, whenever you want to push a value onto one of those subarrays, like you just read a listing? Then do something like push @{$cat->{'birds'}}, $line;.

If you have any further questions, please don't hesitate to ask. :)

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

Replies are listed 'Best First'.
Re: Re: confusing question, involving multidemensional arrays
by Zed_Lopez (Chaplain) on Aug 09, 2001 at 20:15 UTC

    Paco's solution is probably what you want. man perlreftut or see Understand References Today for more info on the subject.

    But there's always the good old-fashioned Perl 4 approach:

    use strict; my %cat; $cat{'bird',0} = 'bluejay'; $cat{'bird',1}= 'oriole'; $cat{'mammal',0} = 'cat'; $cat{'mammal',1} = 'dog'; for (sort keys %cat) { my ($class, $num) = split $;; print "cat[$class][$num] = $cat{$_}\n"; }

    For sparse arrays whose use will be dominated by looking up things by known indices rather than processing rows or columns in a loop, I sometimes still use this. Note that it's inappropriate if your keys might contain binary data, because they can't contain the value of $;, by default \034.