in reply to Re^4: Recover a variable from a loop
in thread Recover a variable from a loop

Declare $white outside the loop if you want to access it from outside the loop - eg. declare it where you declare $self. See Coping with Scoping.

Replies are listed 'Best First'.
Re^6: Recover a variable from a loop
by Chaoui05 (Scribe) on May 26, 2016 at 09:49 UTC
    Good idea but i can't . Because my variable takes a screenshot for a moment of my test's progress. I just want to retrieve it outside my loop. I added some code following if this helps
    Lost in translation
      Sure you can: you declare the variable prior to entering the loop and populate it within the loop. Then you can access it after the end of the loop.
      my $var; for my $c (1..10) { $var++; } print $var; # prints 10