[Peter: what does "Aspirat primo Fortuna labori" mean?  I've gotten a
partial translation, but I'm not satisfied with it.]

On Jan 22, Frank said:

>On Tue, Jan 22, 2002 at 07:39:31AM -0800, Peter wrote:
>> 
>>           $word{$_}++ for /(\w+)/g;
>
>Not to forget Perls default settings for split (the same as \w+).
>
>while(<>){
>    $_{$_}++ for split;
>}

Yours does not match the same "words", though.  Peter's code matches the
words `words' and `though', whereas yours would match `"words",' and
`though.' -- the punctuation makes all the difference.

A thorough word-regex might be needed here, but let's not get into that.

>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. 

Not true.  You are confusing $1, $2, etc., with $& and friends.  If you
use $& once, Perl will prepare it for every regex.  $1 incurs the same
penalty, but only for the regex it is generated from.

I can give you a more thorough explanation of this (or probably any
other) regex query if you'd like.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to