in reply to Update: problem with scalar
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, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Update: problem with scalar
by sargg55 (Novice) on Apr 24, 2016 at 03:14 UTC | |
by tangent (Parson) on Apr 24, 2016 at 04:17 UTC | |
by Laurent_R (Canon) on Apr 24, 2016 at 07:44 UTC |