in reply to foreach and hash of hashes

#!/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;
Basically you're missing a '%' in keys $pupils{$class} <sic>