
sub decrement_count (\%$) {
  my ($hash, $k) = @_;
  die "Tried to decrement nonexistent \$hash{$k}"
    unless $hash->{$k};
  if ($hash->{$k} == 1) { delete $hash->{$k} }
  else { $hash->{$k}-- }
}

1;
