in reply to Problem undefining a variable in a loop using a module causing a list to not empty after use of a subroutine
have also tried to undefine @clsses in the loop. However, like above, no success.
You are declaring @classes inside the loop. Therefore, every time through the loop, the @classes variable is destroyed. A new @classes variable is created each time through the loop and it is assigned a new value.
It's not clear to me why you want to 'undefine' @classes. Is it possible you are doing something like this:
use strict; use warnings; use 5.010; my @classes = ('A', 'B'); for (1 .. 3) { my @classes = ('C', 'D'); say "@classes"; } say "\n@classes"; --output:-- C D C D C D A B
Anything you do to @classes inside the loop braces only affects the @classes variable that you declared inside the loop braces. Changes to the @classes variable inside the loop braces aren't going to affect the @classes variable declared outside the loop braces.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem undefining a variable in a loop using a module causing a list to not empty after use of a subroutine
by amedico (Sexton) on Apr 07, 2010 at 04:18 UTC | |
by Lady_Aleena (Priest) on Apr 07, 2010 at 04:53 UTC | |
|
Re^2: Problem undefining a variable in a loop using a module causing a list to not empty after use of a subroutine
by Lady_Aleena (Priest) on Apr 07, 2010 at 04:49 UTC |