Not sure what exactly you are looking for, but does this help ?
$
$
$ perl -lne 'push @x, $_;
END {print "The input array is as follows:"; foreach (@x){print}
print "Sum = ", eval(join("+",@x));
print "Average = ", eval(join("+",@x))/($#x+1);
}'
10
20
30
40
^Z
The input array is as follows:
10
20
30
40
Sum = 100
Average = 25
$
$
The numbers in blue are input by the user at the command-line.
The text in red is a "Control+Z" and then the "Return" key, and it is an indication to the Perl program that the input has been terminated.
The text in green is printed by the Perl program.
what is I wanted to divide the user input by 2?? THis is my code below...
I know /2 means divide by 2 correct?
[code]
print "The input array divided by 2 is as follows:\n"; foreach (@userArray)/2 {print}
my($sum,$avg) = &sumIt(@userArray);
print "Total:$sum\nAverage:$avg\n";