Last active
August 29, 2015 14:17
-
-
Save paveljurca/1c7dd8508a003927554a to your computer and use it in GitHub Desktop.
word frequency counter (pretty stupid one)
This file contains 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 | |
use strict; | |
use warnings; | |
use utf8; | |
use open qw(:std :utf8); | |
my %word; | |
#single-space-literal split pattern cuts out leading spaces | |
#see http://perldoc.perl.org/functions/split.html | |
while(<DATA>) {$word{$_}++ for split q[ ]} | |
#sorted by the word frequency | |
printf "%-20s ~ %3sx\n", $_, $word{$_} for (sort {$word{$b}<=>$word{$a}} keys %word); | |
__DATA__ | |
„Máme provádět montáže vzduchotechniky, požárních | |
klapek a trafostanic v prostorech, které | |
neodpovídají standardům. Již jsem | |
byla nucena zastavit navážení a montáže ventilátorů vzduchotechniky. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment