> Date: Mon, 8 Apr 2002 23:06:34 -0400 > From: Yanick <[EMAIL PROTECTED]> > > 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. > I was under the impression that sort returned the sorted values and > no references to the original array. I had been using that trick for > at least three solutions when the realisation of what I was doing > sank in (realisation that was of course quickly followed by a > heart-felt 'what in Dante's brimstone-infested third hell...'). I am > still puzzled... Me too... I was looking at something that said "sort map s///,%x", and thinking: If I didn't need the substitution to stick, I could save one character with "map s///,sort%x". Hmmm, let's see what it does, maybe I can save it some way... Hey, funky, it just works! 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. Lars Mathiesen (U of Copenhagen CS Dep) <[EMAIL PROTECTED]> (Humour NOT marked)