in reply to Why is my data structure wrong?
C:\s\pldir>perl -MData::Dumper -e "@a=({}) x 2;print Dumper @a;" $VAR1 = {}; $VAR2 = $VAR1;
When the array is initialized, you end up with the first element being a hash reference, the second element is a reference to the first! I haven't figured out why, yet.
I ran the test without the array initialization (my @data = ({}) x ($rows-1); # need an extra for the header) and Dumper printed the data structure as expected. Is there a reason you need to setup @data in advance? Maybe
push @data, {} for (1 .. $rows-1); would work better if you do?
|
|---|