Help for this page

Select Code to Download


  1. or download this
    sub average {
    @_ == 1 or die ('Sub usage: $average = average(\@array);');
    ...
    foreach (@$array_ref) { $sum += $_; }
    return $sum / $count;
    }
    
  2. or download this
    sub average {
        ref( my $array_ref = $_[ 0 ] ) eq 'ARRAY'
    ...
        return $sum / @$array_ref;
        }