> > Suppose I have a two dimensional hash: > > > > $name{Adams}{Alice} = 1; > > $name{Adams}{Bob} = 2; > > $name{Bull}{Adam} = 3; etc. > > > > Given the first key, is there a way to pull out > > a second key, if I don't care which one? > > my ($first) = keys %{$name{Adams}}; >
That answers the question as asked, but the following is almost certainly more useful: my %adams = %{$name{Adams}}; print $adams{Alice} . "\n"; # prints 1 print $adams{Bob} . "\n"; # prints 1 then you can work from there. This works because of the way multidimensional structures are build... a two dimensional hash is a literal hash of hashes. This means (confusingly at first (and in my expression)): Hash level 1 - keys: Keys of the 1st level Hash level 1 - values: These store REFERENCES to 2nd level hashes Hash level 2 - keys: Keys of the 2nd level Hash level 2 - values: These store the end values (in this case) This is really nice, since it allows you to build tree structures any way you please. By finding out whether a node in that tree has a value or a reference you know if you are on node within the tree, or an end node. My example code, therefore, dereferences the reference to the second hash - allowing us to split of a section of the tree. Apologies due if this makes zero sense. I suggest studing: perldoc perlref Jonathan Paton __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]