in reply to
simple math
You are doing everything right except assigning the first value to $result; try $result = shift(@_) just before the foreach.
Comment on
Re: simple math
In Section
Seekers of Perl Wisdom