Hello sargg55,
foreach my $scalar(@array) { $total+=scalar; }
You’ve named the foreach variable $scalar, but in the loop body you’ve left off the $ sigil. Now, it so happens that scalar is a built-in function in Perl (it puts its argument into scalar context), so the interpreter thinks you’re calling the function — without an argument. Add the sigil:
$total += $scalar;
and it should compile cleanly. See scalar.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Update: problem with scalar
by Athanasius
in thread Update: problem with scalar
by sargg55
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |