Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active August 29, 2015 14:17
Show Gist options
  • Save paveljurca/1c7dd8508a003927554a to your computer and use it in GitHub Desktop.
Save paveljurca/1c7dd8508a003927554a to your computer and use it in GitHub Desktop.
word frequency counter (pretty stupid one)
#!/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