zonmoy has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: not loading all test data
by jasonk (Parson) on Feb 28, 2003 at 18:38 UTC

    Once again we're going to have to ask.

    What was it SUPPOSED to do? This is a variation on the code you asked about earlier in the week, what was wrong with all the answers you got last time you asked it?

    You need to start with the basics, and figure out the difference between the different variable types. Start with perlvar.

      My guess this is a homework question, judged by a previous answer.
Re: not loading all test data
by xmath (Hermit) on Feb 28, 2003 at 18:47 UTC
    Because you're both shifting and counting

    Try this:

    open SCORES, "a:/scores.txt" or die "Error: $! while opening scores fi +le\n"; my $students = 0; my $totalscore = 0; while (<SCORES>) { chomp; my @line = split /:/; while (@line) { my $student = shift @line; my $score = shift @line; print "$student\n$score\n"; $students++; $totalscore += $score; } } print "average: ", $totalscore/$students, "\n" if $students;

    Update: fixed embarrassing typos and minor errors

Re: not loading all test data
by CountZero (Bishop) on Feb 28, 2003 at 21:11 UTC

    Wow, this is such a weird program and without the make-up of the "scores"-file, I can't even start thinking of solving this riddle.

    So much weirdness tonight around. Is there a full moon out?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law