in reply to Generating statistics from data in file

The last number isn't being added because you aren't reading the last number till AFTER you add the $score to $sum.

In other words, when you begin reading the file you're adding $score to $sum before $score even has anything in it. The second line that's read first adds the FIRST score, then sets $score to the second number. And so on. The last number is never added because the loop exits before $sum has a chance to get $score added to it.

Move $sum = $sum + $score to after your split and that should fix it.

In other news, that "float:" stuff you're doing when declaring your variables doesn't do what you think. "float:" is a block name in Perl... it has nothing to do with type declaration. Perl is not a strongly typed language. Variables will be treated as they ought to be treated... numbers as numbers and strings as strings. Most of the time that's The Right Thing, so don't worry about the fact that you can't declare your vars as floats. Because, in most situations, you can't.

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: HELP
by yabba (Initiate) on Apr 08, 2001 at 06:38 UTC
    THANKS AGAIN!!