Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Array of structures within an array of structures.

by Laurent_R (Abbot)
on Sep 20, 2013 at 22:54 UTC ( #1055078=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055078]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2017-02-26 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (371 votes). Check out past polls.