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

Re: [FWP] Comparing two arrays



On Jul 23, abigail@foad.org said:

>On Sun, Jul 23, 2000 at 05:18:16PM -0400, Jeff Pinyan wrote:
>> Yup, I know.  Sadly, Perl doesn't optimize
>> 
>>   ($a,$b,$c) = (split)[-3 .. -1];
>> 
>> the same way it optimizes
>> 
>>   ($a,$b,$c) = (split)[0..2];  # [0..2] optional, I believe...
>> 
>> And if it DOES optimize this, I am highly unaware.  It'd be quite nice of
>> Perl to do this.  How possible is this optimization?
>
>I would be very surprised if Perl could. In general, I don't think it
>possible to extract only the last N fields from a split without creating
>all the fields, because you will never know how much the regexes consume
>of the string if you don't start from the beginning.
>
>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.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/


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