Lingua::EN::Fathom is a Perl module that analyses English text in either a string or file. Totals are then calculated for the number of characters, words, sentences, blank and non blank (text) lines and paragraphs.
Three common readability statistics are also derived, the Fog, Flesch and Kincaid indices.
All of these properties can be accessed through individual methods, or by generating a text report.
A hash of all unique words and the number of times they occur is generated.
my $text = new Lingua::EN::Fathom;
$accumulate = 1;
$num_chars = $text->num_chars;
$num_words = $text->num_words;
$percent_complex_words = $text->percent_complex_words;
$num_sentences = $text->num_sentences;
$num_text_lines = $text->num_text_lines;
$num_blank_lines = $text->num_blank_lines;
$num_paragraphs = $text->num_paragraphs;
$syllables_per_word = $text->syllables_per_word;
$words_per_sentence = $text->words_per_sentence;
%words = $text->unique_words;
foreach $word ( sort keys %words )
$fog = $text->fog;
$flesch = $text->flesch;
$kincaid = $text->kincaid;