in reply to Re: Array of structures within an array of structures.
in thread Array of structures within an array of structures.
Hi VinsWorldcom,
I guess it's a typo, but this part in your code:
$student = ( studentName => 'John', studentSurname=>'Something', studentID=>'9534', age=>'12' ); push @students, $student;
probably does not work properly, as far as I can say. The value of $student is now 12 because you are assigning a list to a scalar, and you're then pushing 12 into @students.
You probably want either directly an hash ref like this:$student = { studentName => 'John', studentSurname=>'Something', studentID=>'9534', age=>'12' }; push @students, $student;
Or an hash on which you later take a ref:
%student = ( studentName => 'John', studentSurname=>'Something', studentID=>'9534', age=>'12' ); push @students, \%student;
|
|---|