in reply to array in for loop
Inside this for loop, each element of @score is aliased to $_, so you can just keep a running total as you loop through the array. If you need to use a C-style for loop as you have, then you'll need to dereference the array using the loop index, maybe like this:my $total = 0; $total += $_ for @score; print "$total\n";
my $total = 0; for (my $ctr=0; $ctr<@score; $ctr++) { $total += $score[$ctr]; # maybe use $ctr for some other purpose as well... } print "$total\n";
-- Mike
--
just,my${.02}
|
|---|