Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by Laurent_R (Monsignor)
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;


Comment on Re^2: Array of structures within an array of structures.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055078]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2015-07-31 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls