in reply to Hash to count characters
Just for grins, here's another way to do it:
#!/usr/bin/perl use strict; use warnings; my %charCount; my $corpus = join('', <DATA>); $corpus =~ tr/A-Z/a-z/d; # Map uppercase to lowercase $corpus =~ tr/a-z//cd; # Delete all but lowercase $charCount{$_}++ for split //, $corpus; for (sort keys %charCount) { print "$_ : $charCount{$_}\n"; } __DATA__ Now is the time for all good men to come to the aid of their party. The quick red fox jumped over the lazy brown dog. The warrior swings the +6 axe at the orcs standing in front of him.
...roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash to count characters
by Anonymous Monk on Aug 12, 2010 at 20:11 UTC |