Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by Laurent_R (Parson)
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 romping around the Monastery: (6)
As of 2014-09-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls