#!/usr/bin/perl

%pbdmcats = ();
%hhpmcats = ();
%numrings = ();
@modifier = (100, 95, 90, 85, 80, 75, 70, 65, 60, 55);

while (<>) {
	chop;					# avoid \n on last field
	($name, $place, $ccount) = split(/\t/,$_);	# split on tabs

	$numrings{$name} = $numrings{$name} + 1;	# track number
							# of scored rings
	$hhpmcats{$name} = $hhpmcats{$name} + ($ccount - $place);
	$pbdmcats{$name} = $pbdmcats{$name} + ($modifier[$place]
						   + ($ccount - $place));
}

	foreach $cat (keys (%hhpmcats)) {
		# print cat's standing by hhp method and by purebred method,
		# cat's name, and number of scored rings in parentheses.
		# Printing the numeric fields first makes sort(1)
		# much easier to use.
	print $hhpmcats{$cat}, "\t", $pbdmcats{$cat}, "\t", 
		$cat, " (", $numrings{$cat}, ")\n";
}
