Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Recover a variable from a loop

by hippo (Bishop)
on May 26, 2016 at 09:36 UTC ( [id://1164180]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1164180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found