I know this is not a working solution to your query but is a one-liner that I have used often to get this type of information quickly for any block of text I am dealing with:
perl -nle '$c{$_}++ for split/\s/;}print map {"$_:$c{$_}\n"} sort{$c{$ +b}<=>$c{$a}}keys %c;{' file_of_WHATEVER_to_count.txt
example, to count the number of instances of each word in a file you could use split/\W/ in the place of split/WHATEVER/ or just split if you wanted to keep punctuation,etc. intact. output is ordered by most frequent occurrences (at the top of the "item:count\n" listing)

In reply to Re: a question about making a word frequency matrix by l3v3l
in thread a question about making a word frequency matrix by peacekorea

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.