I ran your script from a cut-and-paste from your code below. The
program worked exactly as it was expected. The script printed out "0 1 2 3
4 5", paused for 5 seconds, "6 7 8 9 10" continued.
> -----Original Message-----
> From: [EMAIL PROTECTED]
> On Behalf Of Todd Morrison
> 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
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs