On Tue, Jan 22, 2002 at 07:39:31AM -0800, Peter wrote:
> If we accept the set of word characters as being defined by \w, your
> problem can be solved with this code:
>
> my %word;
> while (<>) {
> $word{$_}++ for /(\w+)/g;
> }
---end quoted text---
Not to forget Perls default settings for split (the same as \w+).
while(<>){
$_{$_}++ for split;
}
(It saves about 1 CPU Second for 90000 iterations on my laptop YMMV).
This saves the price of using regex and especially () matches, since
once summoned Perl'll generate $1..$9 for all subsequent regexes, regardless
of if they're needed.
--
Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]