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.
In reply to Re: Problem undefining a variable in a loop using a module causing a list to not empty after use of a subroutine
by 7stud
in thread Problem undefining a variable in a loop using a module causing a list to not empty after use of a subroutine
by Lady_Aleena
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |