You've confused their first and last names. The data is <lname fname score> but you assign those to
$fname, $lname, $score
my %hash = ();
while( <DATA> ) {
my( $lname, $fname, $score ) = split;
$hash{$lname}{$fname} = $score;
}
#just last names
print join "\n", keys %hash;
print "\n---\n";
#names and scores:
for my $lname ( keys %hash ) {
for my $fname ( keys %{ $hash{$lname} } ) {
printf "$lname, $fname: $hash{$lname}{$fname}\n"
}
}
__DATA__
Lateur Bart 97
Pierce Jerrad 96
Unknown planetscape 101
Miller Katie 86
Output:
Pierce
Lateur
Miller
Unknown
---
Pierce, Jerrad: 96
Lateur, Bart: 97
Miller, Katie: 86
Unknown, planetscape: 101