in reply to How to count no of words in a text input file?
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |