print "student: $student :: grades: " . $grades{$student} . "\n"; or print "student: $student :: grades: " . join( ' ', @grades ) . "\n";