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

Re: [FWP] Moment of Zen



Steve Willer wrote:
> 
> On Thu, 30 Sep 1999 lr@hpl.hp.com wrote:
> >
> >       my %shares;
> >       @shares{keys %sites} = map mindshare($_) => values %sites;
> 
> Wouldn't this create a temporary array (the result of map), which would
> then get put into the hash? I would think this would be slower because it
> involves an extra step, and would also use more memory.

It should use twice the memory since it needs one array for the values
and one for the keys.  The foreach approach should only need one for the
keys.
 
> I personally have been a bit appalled by Perl's non-optimization of
> unnamed arrays. Try this:
> 
>   foreach (1..1000000) { dosomething() }

Try it yourself on a newer perl (5.005).  This has been optimized.

-- 
Rick Delaney
rick.delaney@home.com

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