in reply to Average calculation

Untested:
perl -F: -wane '$t{$F[0]}+=$F[2]; $c{$F[0]}++; END{printf "%s: %f\n", $_, $t{$_}/$c{$_} for keys %c}' file
Perl --((8:>*

Replies are listed 'Best First'.
Re^2: Average calculation
by Moron (Curate) on Oct 24, 2005 at 13:19 UTC
    The solution looks accurate, although, especially being terse, some added explanation for this newbie OP, or perhaps where to look in the docs, seems warranted.

    -M

    Free your mind

      Terse, cryptic, partially golfed answers are typically acceptable if the question smells like homework. Consider such to be defense mechanisms of the monestary; good answers to homework questions will attract more homework questions. I, and many others, believe many homework questions would decrease the value of this community.

      -Scott

        Yes I suppose it could be homework, or it could be a totally different real work situation modified into a state, town and temperatures model to get rid of any implied confidential information.

        But if I was sure it was homework, then just giving the code answer is likely to encourage questions from people who want it done rather than those who want to learn. Which group is the more deserving? If anything, I would be inclined to give just hints and/or links to docs rather than just code if deeming it to be homework.

        -M

        Free your mind

      some added explanation for this newbie OP, or perhaps where to look in the docs, seems warranted.
      If you think that it is warranted, what's keeping you from posting it?
      Perl --((8:>*