Created
December 12, 2010 16:43
-
-
Save damienix/738162 to your computer and use it in GitHub Desktop.
Prints words' statistics for file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#: Date : 2010-12-12 | |
#: Author : Damian Skrodzki <[email protected]> | |
#: Description : Prints words statistics for file. | |
open(F, "file") || die("Could not open file!"); | |
@content=<F>; | |
close(F); | |
@words=split(/\W+/, lc "@content"); | |
foreach $w (@words) {%ctrs->{$w}++;} | |
foreach $w (sort {$ctrs{$b} <=> $ctrs{$a}} keys(%ctrs)) {print "$ctrs{$w} - $w\n";} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add reading from all lines (not only first)