Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How to Run a section of code for a particular amount of time ?

by Ratazong (Monsignor)
on Nov 11, 2016 at 09:54 UTC ( [id://1175730]=note: print w/replies, xml ) Need Help??


in reply to How to Run a section of code for a particular amount of time ?

Measure the time spent in the loop and create an additional exit condition. As the main time in your loop is spent sleeping for one second, you may as well count how often the loop has been executed, as shown below

HTH, Rata

my $count = 0; until((@window3=FindWindowLike(undef,"calculator")) || ($count > 29)) { print("\ncan't find window\n"); sleep 1; $count ++; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-29 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found