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

RE: Referenced data changing

2008-09-09 Thread 田口 浩
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($_) } sub test_val { my $p = shift; print test_val

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($_) } sub test_val { my $p =