# create data for small summary table of all retailers my $numWks = (($num_days - ( 7 - $firstDOW_curMonth )) / 7 ) + 1; if ( (($num_days - ( 7 - $firstDOW_curMonth )) % 7 ) ) { $numWks++; } my %dayHash; # the hash my @summary; # the array of hashes # init the blank portion of $summary[][] if there is one #my $temp = 0; #while ( $temp < $firstDOW_curMonth ) { # $summary[0][$temp++] #} my $wktotal; my $count=1; # key into %total_opd, it is based on date (1-$numdays) my $firstDOW = $firstDOW_curMonth; # $wk is index for array for ( my $wk = 0; $wk < $numwks; $wk++ ) { $wktotal = 0; # the first time through $dw may be 0, 1, 2,...6 # $dw is the key of the hash for ( my $dw = $firstDOW; $dw < 7; $dw++ ) { $dayHash{$dw} = $total_opd{$count}; $wktotal += $total_opd{$count}; last if ($count++ == $num_days); } $firstDOW = 0; # next time through the $dw loop it will start at 0 $dayHash{7} = $wktotal; # save the accumulated total for the week push @summary, $dayHash; # last if ($count > num_days); }