On Tue, Apr 09, 2002 at 02:09:30PM -0000, Lars Henrik Mathiesen wrote:
> >     While we are all in a post-mortem mood, could someone explains
> > to me, in simple words of no more than two syllables, why stuff like
> >     map y|w|y|, sort @a; 
> > changes the values of @a?
> 
> OK: It just does, so there.

        The worst thing is, this explanation satisfies me completely.  :)

> > I was under the impression that sort returned the sorted values and
> > no references to the original array. [ but it doesn't ]
> 
> But this is only on 5.6.x, it seems; ask Dave about that. I looked
> through perldelta, which says
> 
>   =head2 Simple sort() using { $a <=> $b } and the like are optimized
> 
>   Many common sort() operations using a simple inlined block are now
>   optimized for faster performance.
> 
> Maybe that's why --- passing through the refs would speed things up.

        Aye, makes sense (kinda). It's a nasty little thing
to keep in mind, though. 

        Oh, and I just tried and 'for(sort @a){s/././};' behaves the same way.

        Weeeeeeird stuff.

Joy,
`/anick


-- 
Life is change. Growth is optional. Choose wisely.
                             -- Karen Kaiser Clark

Reply via email to