precompiled regular expressions
mcdavis941_at_netscape.net
Date: 12/02/03
- Previous message: Paul Kraus: "Mechanize 500 connect failed"
- Next in thread: Rob Dixon: "Re: precompiled regular expressions"
- Reply: Rob Dixon: "Re: precompiled regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 02 Dec 2003 08:42:58 -0500 To: beginners@perl.org
Hi, whats the right way to precompile a regular expression that gets used multiple times without changing.
I don't think I can use /o, because the specific line of code which performs the pattern match is used to check various patterns against various values at various times. None the less, the patterns themselves don't change, once established, and it seems I should be able to save a precompiled regular expression in a variable and use it when it's time to match the corresponding pattern.
The code as it stands looks like this:
if( defined($addr) and $addr =~ /$self->{_rule}/i ) {
$retval = $self->{_confidence};
}
which is an object method used with multiple object instances each having its own value for $self->{_rule}, which is why I can't use /o.
Any help very much appreciated, and yes I am now rereading the documentation.
__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
Get AOL Instant Messenger 5.1 free of charge. Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
- Previous message: Paul Kraus: "Mechanize 500 connect failed"
- Next in thread: Rob Dixon: "Re: precompiled regular expressions"
- Reply: Rob Dixon: "Re: precompiled regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|