: How do i Write a perl script to computer the average word length (
: in characters) and the average sentence length (in words) of a text
: file??? Need to know ASAP!!!
I'll leave you to read the text file into the variable $textIn, that's the easy bit.
As for doing the calculations:-
# Some variables to store the results and workings in.
my $avWordLength = 0;
my $avSentenceLength = 0;
my @wordLengths = ();
my @sentenceLengths = ();
# Get lengths.
push @wordLengths, length($_) for split(/\W+/, $textIn);
push @sentenceLengths, length($_) for split(/\.\s+/, $textIn);
# Do averages.
$avWordLength += $_ for (@wordLengths);
$avWordLength /= scalar @wordLengths;
$avSentenceLength += $_ for (@sentenceLengths);
$avSentenceLength /= scalar @sentenceLengths;
Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");