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
In reply to Re: Re: Modify array elements inside for loops
by merlyn
in thread Modify array elements inside for loops
by sguazt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |