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) {.


DWIM is Perl's answer to Gödel

In reply to Re^3: pre-size a two-dimensional array by GrandFather
in thread pre-size a two-dimensional array by rightfield

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.