$hash{tree} = 4; $hash{tree}->{apple} = 6; $hash{tree}->{apple}->{red} = 9; $hash{tree}->{apple}->{fuji} = 4; $hash{bird} = 4; $hash{bird}->{robin} = 4; $hash{snail} = 4; foreach $key (keys %hash) { print "$key ".$hash->{$key}."\n"; foreach $key2 (keys %{$hash->{$key}}) { print "$key $key2 ".$hash->{$key}->{$key2}."\n"; foreach $key2 (keys %{$hash->{$key}->{$key2}}) { print "$key $key2 $key3 ".$hash->{$key}->{$key2}->{$key3}."\n"; } } }