programming-examples/perl/Hash/Hash of Hashes.pl
2019-11-15 12:59:38 +01:00

23 lines
718 B
Perl

#!/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;
}
}