Hash Of Hashes in Perl

This article demonstrates the implementation of Hash of Hashes



Implementation

#!/bin/perl
my $hashref = {
                Math => { # key
                          "A"  => 100,
                          "H"   => 95,     # values
                        },
                Science => { # key
                          "S"   => 78,
                          "L"   => 100,    # values
                        },
              };

print "$hashref->{'Math'}->{'A'}.\n";
$hashref->{'Science'}->{'L'}=90;
print "$hashref->{'Science'}->{'L'}.\n";

print %{$hashref->{'Math'}}, "\n";   
foreach $key (keys %{$hashref}){
    print "Outer key: $key \n";
    while(($nkey,$nvalue)=each(%{$hashref->{$key}})){
           printf "\tInner key: %-5s -- Value: %-8s\n",$nkey,$nvalue;
    }
}