[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 10:03:23AM -0400, Jeff Pinyan wrote:
>>   map /\0([^\0]*)$/,
>
>    map {substr $_ => 1 + rindex $_ => "\0"}

Nice.  rindex() and index() and substr() are often overlooked in favor of
regex-related solutions (as I often lament in #perl).  I'm surprised I
didn't use that here. ;)

>> (especially if value happens to be an empty string, since the split would
>> remove the empty trailing fields...).
>
>    map {(split /\0/ => $_, -1) [-1]}

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?

-- 
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