my @a = qw(1 2 3); my @b = qw(4 5 6); my @c = qw(7 8 9); my @all = ( \@a, \@b, \@c, ); for my $aref ( @all ){ print $_ for @{ $aref }; print "\n"; } #### 123 456 789 #### my %hash = ( a => 1, b => 2, c => 3 ); print "$hash{ a }, $hash{ b }, $hash{ c }\n"; #output: 1, 2, 3 #### # 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 } };