I'm trying to write a small word counting script - I'm certain there are
zillions out there but it seemed a good learning exercise...
Bascially I read in each line from my text file which I want to count
with a basic while loop and file handle.
The problem is on the count. I know I could split the variable holding
the entire line on each whitespace and load all the components into an
array which I could subsequently count. However this seems a bit crude
and I was wondering if there is a better way to do with regular
expressions which processes each line as a batch.
I know how to test for the occurrence of a 'word' with
$lineFromFile =~ m/\s\w\s/i
However this only tells me if there are individual words in each line.
Is there some way I can count there occurrences? Something involving $1 ?
Thank You :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>