in reply to Re^2: pre-size a two-dimensional array
in thread pre-size a two-dimensional array
I strongly recommend that you use strictures (use strict; use warnings;). That would pick up the use of $numwks and $numWks for example.
It would also alert you to the use of the (presumably) undeclared $dayHash in push @summary, $dayHash; - although I suspect you really intended push @summary, \%dayHash;.
Strictures would also alert you to the use of num_days in last if ( $count > num_days ); which seems pretty unlikely given you've used $num_days a few lines up
In answer to your actual question: yes, you will be pushing copies of the reference. The easy fix is to make %dayHash (and $wktotal btw) local to the loop:
for ( my $wk = 0 ; $wk < $numWks ; $wk++ ) { my $wktotal = 0; my %dayHash; ... }
I notice that $wk is not used. You could just for (1 .. $numWks) { and if you do need it at some point you should for my $wk (1 .. $numWks) {.
|
|---|