[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: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...

perl doesn't optimize either of those.  If you want the optimization, you
have to write:

($a,$b,$c) = split;

_without_ the list slice.


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

The first argument to split is a regex, so I think this optimization would
not be possible at all.  Perhaps in the most trivial cases, such as /a/,
but then you wouldn't save much in an optimization anyway.

Ronald

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