grep is right-the problem is in the foreach in your total function. By saying @_[$_] inside your loop, you are using values from the array passed in (@fred) to pick the items to add.
A similar situation will occur if the user provides numbers that exceed the number of values they provide.
HTH.
In reply to Re: Having problems with addition in sub
by atcroft
in thread Having problems with addition in sub
by bluethundr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |