Help for this page

Select Code to Download


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