#!/usr/bin/perl -w use strict; my %playerHoH = ( Bennie => { deaths => 1, kills => 13 }, Bob => { deaths => 12, kills => 15 }, Jane => { deaths => 0, kills => 30 }, mary => { deaths => 4, kills => 20 }, ); $playerHoH{Harry}{deaths} += 4; $playerHoH{Harry}{kills} += 20; foreach my $name (keys %playerHoH) { print "$name "; #prints: Jane Bob Harry mary Bennie } print "\n"; #again Jane Bob mary Bennie must be and are unique. #the hash forces them to be that way foreach my $name (keys %playerHoH) { my $hash_ref = $playerHoH{$name}; #the value is a reference #to another hash! foreach my $key (keys %$hash_ref) { ### these 2 formulations are equivalent and print ### the same thing print "One way: $name: $key => $hash_ref->{$key}\n"; print "Another way: $name: $key => $playerHoH{$name}{$key}\n"; } print "\n"; } =above prints: One way: Jane: deaths => 0 Another way: Jane: deaths => 0 One way: Jane: kills => 30 Another way: Jane: kills => 30 One way: Bob: deaths => 12 Another way: Bob: deaths => 12 One way: Bob: kills => 15 Another way: Bob: kills => 15 One way: Harry: deaths => 4 Another way: Harry: deaths => 4 One way: Harry: kills => 20 Another way: Harry: kills => 20 One way: mary: deaths => 4 Another way: mary: deaths => 4 One way: mary: kills => 20 Another way: mary: kills => 20 One way: Bennie: deaths => 1 Another way: Bennie: deaths => 1 One way: Bennie: kills => 13 Another way: Bennie: kills => 13 =cut