#!/C:\Perl64\bin\perl.exe use strict; use warnings; my @numlist = qw(2 4 4 4 5 5 7 9); my $numlist_avg = avg(@numlist); my @cands; my @abvlist = abv(@numlist); my $sigma = std_dev(@numlist); my @squares; my $len = $#numlist + 1; print "The count of numbers in \@numlist is ", $#numlist + 1, "\.\n"; print "The total of \@numlist is ", total(@numlist), "\.\n"; print "The mean average of \@numlist is ", avg(@numlist), "\.\n"; print "The list of numbers in \@numlist over the mean is ", join(',', @abvlist), "\.\n"; print "The list of numbers that will probably be duplicates in \@numlist over the mean is ", join(',', abv(@numlist)), "\.\n"; print "The standard deviation of numbers in \@numlist is ", $sigma, "\.\n"; sub total { my $endresult = 0; foreach my $x (@numlist) { $endresult += $x; } return $endresult; } sub avg { my $len1 = $#numlist + 1; return total(@numlist) / $len1; } sub abv { foreach my $cand (@numlist) { if ($cand > $numlist_avg) { push(@cands, $cand); } } return @cands; } sub std_dev { my $len2 = $#numlist + 1; foreach my $num (@numlist) { my $step1 = $num - $numlist_avg; my $step2 = $step1 * $step1; push(@squares, $step2); } my $start2 = 0; foreach my $num2 (@squares) { $start2 += $num2; } return sqrt($start2 / $len2); }