Re: Referenced data changing

2008-09-10 Thread Chris Wagner
Ohayou. I think what ur asking is why does @code change when u loop over it with foreach, ne? This is because foreach only takes a reference to the list values, it doesn't create a copy. So changing the iterand changes the original value. If u don't want this u have to make ur own copy of the v

RE: Referenced data changing

2008-09-09 Thread Brian Raven
?? ? <> wrote: > I have some misunderstanding. > > The next code has the same behaviour. > But I was thinking differently... > > #!/usr/bin/perl > use strict; > print "TEST3 start...\n"; > my @code; > push @code, "01"; > push @code, "02"; > push @code, "03"; > > for (1..2) { test_val($_) } > >

RE: Referenced data changing

2008-09-08 Thread 田口 浩
l p=2 val1=1 val2=1 val1=2 val2=2 val1=3 val2=3 > -Original Message- > From: H.T. > Sent: Tuesday, September 09, 2008 2:30 PM > To: 'perl-win32-users@listserv.ActiveState.com' > Subject: Referenced data changing > > Hello, > > I'm just maintain this

Referenced data changing

2008-09-08 Thread 田口 浩
Hello, I'm just maintain this odd script. On the code; foreach my $val (@{$$code{"1"}}) { I think $val is lexical but in the 2nd call of test_val the data is changed. I don't want it. I must code like; my $val2 = $val; $val2 =~ s/^0+//; to avoid the changing. I cann't understand why? #