Deb <[EMAIL PROTECTED]> writes: > > I understand this: > > foreach $listname (sort keys %Lists) { > print "$listname\n"; > } > > But, I don't quite get how to get to the key values > below that. I know I'm so close, but just not quite > there... > > Could some kind soul give me a blow by blow "what's > happening here" going from > > $Lists{$listname} = \%hrLists; > > to printing out the key, values by $listname? >
Don't mean to thump the FM, but have you seen the "Access and Printing of a HASH OF HASHES" section in perldsc? Your %Lists is a perfect %HoH. But anyway, as you've probably seen, the ordinary "print a hash" loop... for my $key (sort keys %Lists) { print "$key => $Lists{$key}\n"; } Produces something like this. list-1 => HASH(0x80fb32c) Where "HASH(0x80fb32c)" represents the hash reference. you created way... back.. here: $Lists{$listname} = \%hrLists; # ^ # backslash creates a reference # So what you've got is a nested data structure; a hash (%List) whose values are references to more hashes. To print it out, you just need two loops, an outer loop for %Lists, and an inner loop to iterate over the nested hashes. for my $list (sort keys %Lists) { print "$list: \n"; my $ref = $Lists{$list}; # # use "%{$ref}" to dereference # for my $key (sort keys %{$ref}) { print " $key : $ref->{$key}\n"; } } And besides perldsc, you might find these handy if you're learning/working-with references: $ perldoc perlreftut $ perldoc perlref -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]