Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2016-09-29 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (548 votes). Check out past polls.