push @{$students{$student_id}}, $course_id; # ... then to retrieve later ... for my $cid (@{$students{$student_id}}) { print "Course ID $cid, Tutor: $catalog{$cid}{tutor}\n"; # or whatever }