sub read_countries {
    open(C, "/mit/marc/Classes/urop/Iap96/countries")
	|| die "open countries: $!\n";

    while(<C>) {
	/\"([^\"]*)\",\s+\"([^\"]*)\",\s+\"([^\"]*)\",\s+\"([^\"]*)\"/;

	$regions{$1}++;
	$subregions{$1."-".$2}++;
	$coderegion{$3} = $1;
	$codesubregion{$3} = $1."-".$2;
	$nameregion{$4} = $1;
	$namesubregion{$4} = $1."-".$2;
    }

    close(C);
}

sub table {
    local($ary, $by) = @_;

    ($by = "regions") if !$by;

    print "\U$ary by $by:\n";

    print "time     \t";
    for $region (sort keys %{$by}) {
 	printf "%20s    %%age",$region;
    }
    print "\ttotal\n";

    for $month (sort keys %{$ary}) {
	print $month," \t";
	for $region (sort keys %{$by}) {
	    if ($$ary{$month}{"total"}) {
		printf ("%20.0lf%8.4lf",
			$$ary{$month}{$region},
			$$ary{$month}{$region}/$$ary{$month}{"total"});
	    } else {
		print " "x28;
	    }
	}
	print "\t",$$ary{$month}{"total"},"\n";
    }

    print("\n");
}

1;
