David L. Nicol writes:
: What if there were a faster way to do this, a way to C<study> a
: group of regexes and have the computer determine which ones had
: parts in common, so that if $situation =~ m/^foo/ is true, the
: fifty rules that start ^bar don't waste any time.  At all.

Perl 4 did this sort of thing automatically without a study, at least
with respect to the first character that could match.  Of course, it
didn't do it with regular expressions in an array, but rather in
a "switch" structure.  And you had to bunch your tests right.  If
your regular expressions were in an array, you had to use eval.

So certainly there's room for an interface that can take multiple regex
objects and turn them into a single super regex.  I don't think the
code to do it necessarily belongs in the core, but it would certainly
have to be somewhat incestuous with regex innards.

Larry

Reply via email to