A partial solution, but better than nothing:
#!/usr/bin/perl $_=<DATA>; $h{$_}++,$c++,$h{$_}>$n?($n=$h{$_},$m=$_):++$k for map {lc}m/\w+/g; $_="$c words\nmax: '$m' ($n times)$\avg count:".($c/keys %h).$\; print;BEGIN{$\=$/;$/=q//; $,=":"} print@a while@a=each%h; __DATA__ But, in a larger sense, we can not dedicate—we can not consecrate—-we +can not hallow—-this ground. The brave men, living and dead, who stru +ggled here, have consecrated it, far above our poor power to add or d +etract. The world will little note, nor long remember what we say her +e, but it can never forget what they did here. It is for us the livin +g, rather, to be dedicated here to the unfinished work which they who + fought here have thus far so nobly advanced. It is rather for us to +be here dedicated to the great task remaining before us — that from t +hese honored dead we take increased devotion to that cause for which +they gave the last full measure of devotion — that we here highly res +olve that these dead shall not have died in vain — that this nation, +under God, shall have a new birth of freedom — and that government of + the people, by the people, for the people, shall not perish from the + earth

Update: now with average.


In reply to Re: How to count no of words in a text input file? by moritz
in thread How to count no of words in a text input file? by vikramkone

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.