Begin forwarded message:
On Aug 23, 2007, at 4:25 PM, Mr. Shawn H. Corey wrote:
# How about?
my ( $year, $month, $doy, $tmax, $tmin, $par, $precip, $NH4, $NO3,
$O3, $CO2, $V1, $V2, $V3, $V4 ) = split;
# You can now store your totals by month as:
$totals{$year}{$month}{tmax} += $tmax;
...
# and the count
$totals{$year}{$month}{count} ++;
# After you read all the input, you can calculate the averages.
Interesting idea. I like it in that it is flexable (for example I
could easily print the monthly sum of precip by not dividing by a
"count", which brings me to my question. I see how you are summing
each of the variables like tmax with:
+= $tmax;
I'm not sure though how you are keeping track of the "count". In
order to print out averages, I'd have to do something like:
print $year, $doy / count, $tmax / count, $tmin / count
I don't see how $totals{$year}{$month}{count} ++; is holding the count.