in reply to Array of structures within an array of structures.

G'day atu,

Welcome to the monastery.

You have some syntax errors there (e.g. my $student = (...); my $student = (...);). Use the strict and warnings pragmata to get feedback from Perl: see my code below for usage.

I'm guessing you're probably after something like this:

#!/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;

Output:

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 } ];

I'd recommend you look at "perldsc - Perl Data Structures Cookbook" which describes these types of structures in detail.

-- Ken