in reply to Re: How to code a complex AoH?
in thread How to code a complex AoH?
points => \@points,
Actually, that won't work here - it looks like iatros isn't using strict, or has predeclared @points outside of the loop, so that \@points and therefore $$student{points} will always point to the same array, and that array will get overwritten on each iteration of the loop. points => [@points], will work correctly, since it creates a (shallow) copy of the array. (Athanasius, I know you know all this, the explanation is for the benefit of the OP.)
iatros: You really should Use strict and warnings, and then use my to declare your variables, including inside the loop: my ( $id , $gender , $birthday ... ) = .... Then you can use both of the code examples that Athanasius showed, because then on each iteration of the loop, @points will be a "new" array.
Update: Tweaked explanation a tiny bit.
|
|---|