in reply to Statistics from a txtfile
To get the statistics you want, it may be easier to slurp the whole file into a variable then process it through a series of regexes. Here's the basic idea, but as suaveant suggests - read up on regular expressions:
open (READFILE, $filename)|| die "Failed to open $filename: $!"; my $filecontents; { local undef $/; $filecontents = <READFILE>; } close <READFILE>; my @words = $filecontents =~ / ... /g; my $wordcount = scalar @words; my @characters = ... my @sentences = ... # etc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Statistics from a txtfile
by mbdc566021 (Initiate) on Dec 30, 2007 at 15:49 UTC | |
by hangon (Deacon) on Dec 31, 2007 at 19:44 UTC | |
by blazar (Canon) on Jan 02, 2008 at 21:17 UTC | |
by hangon (Deacon) on Jan 03, 2008 at 03:36 UTC |