#!/afs/athena/contrib/perl5/p -w

use strict;
use vars qw( $tot $gtot $prt $val );
$tot = $gtot = 0;

sub conv ($) {
  my $s = sprintf "%8.2f", $_[0];
  $s =~ s/\.?0+$//;
  $s;
}

while (<>) {
  /^\s+$/
    && ( $prt && printf("total:       %s\n\n", conv $tot), $prt=$tot=0, next );
  /total:/ && next;
  print;

  chop;
  ($prt, $val) = split(/:/);
  $val =~ /^\s*\d/ || next;
  $tot += $val;  $gtot += $val;
  die "too many hours: $prt\n" if ($tot > 40);
}

printf "grand total: %s\n", conv $gtot;
