sub mean { my $result; foreach (@_) { $result += $_ } return $result / @_; } my @points = qw(1 2 3 4); print mean @points;