{ local $/ = undef; # Read everything in one go $_ = lc(); s/[^a-z]//g; # Get rid of nonalphabetic characters for my $letter ('a'..'z') { my $count = s/$letter//g; # Magic! print "$letter = $count\n"; } }