#!/usr/bin/perl use strict; use warnings; use List::Util qw/sum/; my @list = (1, 2, 4, 2); my $avg = avg(@list); print $avg, "\n"; exit; sub avg { my $sum = sum @_; my $len = scalar @_; return $sum/$len; }