On Wed, 16 Aug 2000, Jonathan Scott Duff wrote:
> On Wed, Aug 16, 2000 at 07:39:33AM -0700, Dave Storrs wrote:
> > How about instead we build the DFA [regex engine], with its more
> > limited syntax, but it must be manually turned on by use of a flag
> > (similar to the 'o' precompiled flag)?
>
> /o means "compile once" not "precompile" I think you're thinking of
> qr//
D'oh! I knew that. Thanks.
> > Actually this could be a good thing in general...when you're
> > writing a frequently-used and hairy regex, you could set the 'precompile'
> > and 'use DFA' flags to get maximum speed.
>
> $/ = qr/[\r\n]/f; # fast ?
Sure. Although, I'd like to see the option be 'd', for 'DFA'.
That makes it easy to remember that you are using an entirely different
engine, one which trades expressiveness for speed.
In case it wasn't clear, I also see this as valid anywhere that
you might do a regex match:
for (@million_email_addys) {
if ( /\.gov/d ) { lobby(); }
}
(N.B. This example is not intended to be optimized for a DFA,
and the regular RE engine might well be just as good here.)
Dave