in reply to Having problems with addition in sub
$number += @_[$_]; ==>this is the mistake.
When you pass the array to the function, the default @_ will grab everything and store it.
And when you use the foreach, $_ will loop through the entire array and will have the current value when you process it.
Correct usage should be:
======================= $number += $_;
Your proglet works fine after this.
Hope you understood now :-)
-Anand
Code tags added by GrandFather
|
|---|