- or download this
my $sum = 0;
$sum += $_ for @total;
my $average = $sum / @total;
- or download this
my $average = 0;
$average = ($_ * $average + $total[$_]) / ($_ + 1) for 0 .. @to
+tal -1;
- or download this
perl -lane '$a = (($. -1) * $a + $F[2])/$.; END{print $a}' file
- or download this
perl -lpe '$,+=$_}{$_=$,/$.' file