in reply to How To Do This Better?

One optimization right off the bat, if the string contains much more than 52 characters:
s/([a-zA-Z])/{ $count{$1}++; $1 }/eg while <>; foreach (A .. Z) { $count{lc($_)} += $count{$_} || 0; }
Disclaimer: untested, but theoretically valid. (corrected on 15 April as turnstep noticed a typo)