diff --git a/charhist/charhist.pl b/charhist/charhist.pl index 8460480..5b459dd 100644 --- a/charhist/charhist.pl +++ b/charhist/charhist.pl @@ -16,10 +16,14 @@ if (@ARGV) { readfile(); } +my $total = 0; +$total += $_ for values %hist; + binmode STDOUT, ":encoding(UTF-8)"; for (sort keys %hist) { my $cp = ord; - printf("%x %d %o %s\t%d\n", $cp, $cp, $cp, /\p{Graph}/ ? $_ : ".", $hist{$_}); + printf("%x %d %o %s\t%8d %f\n", + $cp, $cp, $cp, /\p{Graph}/ ? $_ : ".", $hist{$_}, $hist{$_} / $total); } sub readfile {