Hello Todd,

It's weird, because I tried your piece of code and it work the way you
expect it to work:
Print 0 to 5, wait 5 seconds print 6 to 10.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Todd Morrison
Sent: Wednesday, February 08, 2006 3:29 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Can sleep() be conditional?

Hello!

I was wondering if anyone knows/has had experience with using sleep() in
a 
conditional context. For example...

for ($x=0; $x<= 10; $x++) {
         print "$x\n";
         # if x is equal to 5, sleep for 5 seconds
         if ($x == 5) { sleep(5); }
}

What I wanted to accomplish with this loop was to have the iteration run

until the condition was met, at which point the loop would sleep for 5 
seconds. Is there a way I can accomplish this? When I run the code,
above, 
what actually happens is the entire script/code waits for 5 seconds and 
*then* launches the loop.

Any advice or direction would be super.

Thanks!

Todd


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to