in reply to Re^2: Weighted averages
in thread Weighted averages

The data is read line by line. So each new line you get a new iteration of the loop, a new array, which starts at 0 again.

Using my code and your sub, you could just write: say "Weighted average: ", quiz(@fields[FIRST_QUIZ..LAST_QUIZ]) + exam(@fields[FIRST_EXAM..LAST_EXAM]) + final($fields[FINAL])

Replies are listed 'Best First'.
Re^4: Weighted averages
by drose2211 (Sexton) on Jan 25, 2018 at 17:53 UTC

    Ah yes, that makes sense. Ok I am going to go and mess around with that a bit. Thanks for the help.