in reply to Re: confusing question, involving multidemensional arrays
in thread confusing question, involving multidemensional arrays

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.