At 10/16/03 07:00 AM , Chris Santerre wrote:
Ok, perl gurus! If I but ?: in front of all my evilrules like so:

/?:www\.spamhost\.com/i
or
/?:(www\.spamhost\.com)/i

Would the rules be faster? Because I can make that change on the end of the
month run. And does this basically mean, "Forget about what came before
this."?

Not quite. You put the ?: on the *inside* opening of a pair of parentheses, and it tells Perl "these parens are just for grouping; you don't need to actually remember what's in them for later backreferences". So, assuming you're not going to be doing anything involving $1, $2, etc, you can say things like:


/www\.(?:spamhost|evilspammer|nastyporn)\.com/i

Then Perl won't waste memory on remembering "spamhost", "evilspammer" or "nastyporn".

This isn't likely to be noticeably faster, but will reduce memory usage by at least a bit. And it only works on parentheses -- indeed, the operator is listed in the Camel Book's index as (?:) (and it's on page 68). In your second example, which would be /(?:www\.spamhost\.com)/i , I can't see any reason to use the parens at all, unless you actually *intend* to capture that text for some later use.

Hope this helps, even if it actually means you have no use for the operator.

                                                --Kai MacTane
----------------------------------------------------------------------
"I looked Death in the face last night,/I saw him in a mirror,
 And he simply smiled,/He told me not to worry:
 He told me just to take my time."
                                                --Oingo Boingo,
                                                 "We Close Our Eyes"



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to