[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Comparing two arrays



On Sun, Jul 23, 2000 at 05:39:07PM -0400, Jeff Pinyan wrote:
> On Jul 23, abigail@foad.org said:
> 
> >But there might be a way to optimize it if it's determined that the regex
> >doesn't contain any metacharacters.
> 
> That is what I hoped for.
> 
> Oh, and I have heard requests for an /r modifier to regexes to make them
> start from the back of the string... that would come in handy here, among
> other places.

No, as that will not help. You cannot start from the end to optimize
something without changing the outcome in general. Consider the string
"bacadaeaf" and a split on /a.*/. The outcome will be quite different
if the regex would be applied "from the end".

That of course does not mean that a /r would not be useful, and a 
split /regex/r would be useful as well, but you cannot optimize

   (split /regex/, string, -1) [-1];

to

   (split /regex/r, string, 2) [1];

You would still need the same assumptions as I mentioned before, and given
those, /r become a separate issue.


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe