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

For this variable yes. I've just done it. But for $white, it's done .
Lost in translation

Replies are listed 'Best First'.
Re^5: Recover a variable from a loop
by hippo (Archbishop) on May 26, 2016 at 09:36 UTC

    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.

      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