#!/usr/bin/env perl -l use strict; use warnings; use Data::Dumper; my @classrooms; my @students = ( { studentName => 'John', studentSurname => 'Something', studentID => 9534, age => 12 }, { studentName => 'Mary', studentSurname => 'Something2', studentID => 5489, age => 13 }, ); my %classroom = ( classroomID => 10, classroomName => 'classroom1' ); push @{$classroom{students}}, @students; push @classrooms, \%classroom; print 'Name of 1st student in 1st classroom: ', $classrooms[0]{students}[0]{studentName}; print 'The whole school:'; print Dumper \@classrooms; #### Name of 1st student in 1st classroom: John The whole school: $VAR1 = [ { 'classroomName' => 'classroom1', 'students' => [ { 'studentSurname' => 'Something', 'studentID' => 9534, 'studentName' => 'John', 'age' => 12 }, { 'studentSurname' => 'Something2', 'studentID' => 5489, 'age' => 13, 'studentName' => 'Mary' } ], 'classroomID' => 10 } ];