title: counting letters for each word in a text with Perl
body: <p>I am trying to write a program wit Perl which should returns the frequency of all words in the file and the length of each word in the file (not the sum of all characters!) to produce a Zipf curve from a Spanish text (is not a big deal if you don't know what a Zipf's curve is). Now my problem is: I can do the first part and I get the frequency of all word but I don't how to get the length of each word! :( I know the command line 
  <strong>$word_length = length($words)</strong> but after trying to change the code I really don't know where I should include it and how to count the length for each word.</p>
  
  <p>That's how my code looks like until know:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  
  my %count_of;
  while (my $line = &lt;&gt;) { #read from file or STDIN
    foreach my $word (split /\s+/gi, $line){
       $count_of{$word}++;
    }
  }
  print "All words and their counts: \n";
  for my $word (sort keys %count_of) {
    print "$word: $count_of{$word}\n";
  }
  __END__
  </code></pre>
  
  <p>I hope somebody have any suggestions!</p>