From e27477085c035a5268a85af1b97b3857cc483663 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 13 Sep 2018 19:02:40 +0200 Subject: [PATCH] Print share --- charhist/charhist.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 {