Re: for(sort@a){...} affects @a

2002-04-11 Thread Yanick
On Thu, Apr 11, 2002 at 04:10:27PM +0200, Eugene van der Pijll wrote: > Does that make sense? Perversely, it does. :) Thank for you and the others to shed light on this most interesting feature. And to remember the lesson, what is better than to convert it into a yaph? Joy, `/an

Re: for(sort@a){...} affects @a

2002-04-11 Thread Lars Henrik Mathiesen
> Date: Thu, 11 Apr 2002 15:28:36 +0100 > From: Adam Spiers <[EMAIL PROTECTED]> > > These are two sides of the same coin, and not really very surprising, > when you think about how modifying a key potentially means moving it > to a new hash bucket. That would be ugly. During the tournament, I di

Re: for(sort@a){...} affects @a

2002-04-11 Thread Lars Henrik Mathiesen
> Date: Wed, 10 Apr 2002 17:00:41 -0400 > From: Yanick <[EMAIL PROTECTED]> > > On Wed, Apr 10, 2002 at 02:48:54PM -0400, Karger, Amir wrote: > % perl -wle '@a=qw(e d c b a); for(map $_, @a){s/./uc($&)/e};print @a' > edcba > > BUT > > % perl -wle '@a=qw(e d c b a); for(grep $_, @a){s/./uc(

Re: for(sort@a){...} affects @a

2002-04-11 Thread Lars Henrik Mathiesen
> Date: 11 Apr 2002 14:22:22 - > From: Lars Henrik Mathiesen <[EMAIL PROTECTED]> > > > Date: Thu, 11 Apr 2002 16:10:27 +0200 > > From: Eugene van der Pijll <[EMAIL PROTECTED]> > > > No, values are modified, keys are not. But that's not so strange: hash > > values are scalars; hash keys are s

Re: for(sort@a){...} affects @a

2002-04-11 Thread Adam Spiers
Yanick ([EMAIL PROTECTED]) wrote: > On Thu, Apr 11, 2002 at 09:04:22AM -0400, Karger, Amir wrote: > > I get the same result as you (aBcD) when I run 5.6.1 on > > solaris. So it looks like the aliasing mechanism switched from > > 5.004 to 5.6.1. > > I get the same behavior: > > $ perl -v >

Re: for(sort@a){...} affects @a

2002-04-11 Thread Lars Henrik Mathiesen
> Date: Thu, 11 Apr 2002 16:10:27 +0200 > From: Eugene van der Pijll <[EMAIL PROTECTED]> > No, values are modified, keys are not. But that's not so strange: hash > values are scalars; hash keys are strings: > > $ perl -le'$a{[1,2,3]} = [4,5,6]; print "$_: @$_" for %a' > ARRAY(0x140001ad0): > AR

Re: for(sort@a){...} affects @a

2002-04-11 Thread Eugene van der Pijll
En op 11 april 2002 sprak Yanick: > $ perl -v > This is perl, v5.6.1 built for i386-linux > $ perl -le'%a = qw/ a b c d/; s/./uc$&/e for %a; print %a' > aBcD > > And this one really takes the cake. Keys are modified, > but not values... But wait! There is more! No, values are modified, key

Re: for(sort@a){...} affects @a

2002-04-11 Thread Yanick
On Thu, Apr 11, 2002 at 09:04:22AM -0400, Karger, Amir wrote: > I get the same result as you (aBcD) when I run 5.6.1 on solaris. So it looks > like the aliasing mechanism switched from 5.004 to 5.6.1. I get the same behavior: $ perl -v This is perl, v5.6.1 built for i386-linux $ perl -le

RE: for(sort@a){...} affects @a

2002-04-11 Thread Karger, Amir
3 AM > To: Karger, Amir > Subject: Re: for(sort@a){...} affects @a > > > Hello Amir! > > On 10 Apr 2002, you wrote in perl.golf: > > > Some more data? > > > >>perl -wle '%a=qw(a b c d); for(%a){s/./uc$&/e};print %a' > > abcd > >

Re: for(sort@a){...} affects @a

2002-04-10 Thread Yanick
On Wed, Apr 10, 2002 at 02:48:54PM -0400, Karger, Amir wrote: > In fact, it's not just sort: > > >perl -wle '@a=qw(e d c b a); for(reverse @a){s/./uc($&)/e};print @a' > EDCBA Egad! But: % perl -wle '@a=qw(e d c b a); for(map $_, @a){s/./uc($&)/e};print @a' edcba BUT % perl -wl