# define the list of students per each class my @room1_pupils = qw( steve mike melissa ); my @room2_pupils = qw( meredith alexa chris ); # create the school, and assign the student lists to each # hash key my %school = ( room1 => \@room1_pupils, room2 => \@room2_pupils, ); # now you can get a list of students by room name (through # the reference) my @students = @{ $school{ room2 } };