Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Counting wordsby PetaMem (Priest) |
on Aug 24, 2002 at 20:25 UTC ( [id://192580]=note: print w/replies, xml ) | Need Help?? |
Hi there, well - since you use #!/usr/bin/perl you probably have wc at your fingertips. wc -w <file> could do what you want. You could just backtick it in your perl script. But then again this wouldn't be portable. Then, there is CPAN. String::ParseWords could be interesting. Or look there! wc in a portable manner! For a simple task all this may seem good enough. But when it comes to real word counting you first need to tokenize your text. Tokenizing is an art for itself. Have a look at This Book if you're really into it. And don't forget to make it unicode safe. :-)
Bye
In Section
Seekers of Perl Wisdom
|
|