in reply to Re^2: Calculating Row Averages From a CSV File
in thread Calculating Row Averages From a CSV File
Place this after shift @f.
my $row_sum; @f = grep { $_ } @f; $row_sum += $_ for @f; print "Row average = ", $row_sum / @f, "\n";
Given:
AAA01,0,0,0,0,0,1 AAA02,0,0,0,0,1,2
produces:
Row average = 1 Row average = 1.5
update: Fixed error pointed out here by rayv
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Calculating Row Averages From a CSV File
by rayv (Novice) on Aug 15, 2007 at 13:30 UTC | |
by FunkyMonk (Bishop) on Aug 15, 2007 at 14:16 UTC | |
by rayv (Novice) on Aug 15, 2007 at 14:34 UTC | |
by FunkyMonk (Bishop) on Aug 15, 2007 at 14:49 UTC |