Basically you're missing a '%' in keys $pupils{$class} <sic>#!/usr/bin/perl use strict; use warnings; my %pupils = ( 'Foo 101' => { 'Bob' => 88, 'Sally' => 99 }, 'Foo 102' => { 'Jesse' => 68, 'Raphael' => 93 } ); my $class_to_check = "Foo 102"; my @namelist; foreach my $nm ( keys %{$pupils{$class_to_check}} ) { push @namelist, $nm; } print "Student in $class_to_check: $_\n" foreach @namelist;
In reply to Re: foreach and hash of hashes
by Transient
in thread foreach and hash of hashes
by momo33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |