I can only guess at what you intended but here's what you probably meant to say. (in two different versions). You'll probably also want to use a different variable name than $a because that is special and will be clobbered if you use sort(). ($b is also special, skip that one too).
# Better for (@score) { print "$_\n"; $a += $_; } $dev += $#score; print $dev; # Less nice for (my $ctr = 0; $ctr < @score; $ctr++ ) { print "$score[$ctr]\n"; $a += $score[$ctr]; } $dev += $#score; print $dev;
Seeking Green geeks in Minnesota
In reply to Re: array in for loop
by diotalevi
in thread array in for loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |