in reply to array in for loop
Well, that depends on what you are trying to accomplish. To me, it looks like you actually want to do something like:
@score = qw( 1 2 3 5 8 13); for($ctr=0; $ctr<@score; $ctr++){ print "$score[$ctr]\n"; $a = $a + @score[$ctr]; $dev++; print "$dev"; }
Right? However, a better way to do this would be:
@score = qw( 1 2 3 5 8 13); foreach $score (@score){ print "score is $score\n"; $a += $score; print "dev is " , ++$dev , "\n"; } print "a is $a \n";
LAI
:eof
|
|---|