in reply to Re: Modify array elements inside for loops
in thread Modify array elements inside for loops
local @a = (1 .. 9); # How can I use my here
{
for my $e (local @a) {
$e += 1;
}
}
Your inner local @a there creates a new @a with an empty list. Add a print $e inside to see that.
See the other answers in this thread for more correct answers.
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Modify array elements inside for loops
by arhuman (Vicar) on Mar 06, 2001 at 21:49 UTC |