in reply to HOW to calculate the column data

Since there's already been fish thrown . . . FORE!

perl -lane '/^N2O-(\d+)/;$t{$1}+=$F[-1];$c{$1}++;END{for(sort{$a<=>$b} +keys%t){printf"N2O-$_ %0.3f\n",$t{$_}/$c{$_}}}'

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: HOW to calculate the column data
by jwkrahn (Abbot) on Dec 03, 2009 at 21:33 UTC

    If you just want to make it short:

    perl -ane'$t{$F[0]}+=$F[1];$c{$F[0]}++}{printf"$_ %.3f\n",$t{$_}/$c{$_ +}for+sort+keys%t'