#!/usr/bin/perl my @fred = qw{ 1 3 5 7 9 }; sub total { my $sum = 0; my @array = @_; foreach $number (@array) { $sum = $sum + @array[$number]; } return $sum; } my $fred_total = &total(@fred); print "The total of \@fred is $fred_total.\n"; print "Enter some numbers on separate lines: "; my $user_total = &total(); print "The total of those numbers is $user_total.\n"; ~ ~