On Tue, 30 Jan 2001 04:13:39 -0500, Michael G Schwern wrote: >Is there any really good reason why sleep() doesn't work for >microseconds? I mean, if I can do this: > > sub sleep { > my($time) = shift; > if( /^[+-]?\d+$/ ) { > sleep($time); > } > else { > select(undef, undef, undef, $time); > } > } > >Why can't Perl? One of your problems is that sleep(3) is NOT garanteed to sleep exactly 3 full seconds. It's only garanteed that the difference between time() before, and after, will be (at least) 3. So sleep 3 actually just has to wait for 3 time second rollovers. That may take for example only 2.5 seconds. Well, that's how it *used* to be. Maybe perl's behaviour has been changed since then. If you expect sleep(2.5) to work properly, then sleep(3) should be fixed, too. -- Bart.
- Re: Why shouldn't sleep(0.5) DWIM? Branden
- Re: Why shouldn't sleep(0.5) DWIM? Stephen P. Potter
- Re: Why shouldn't sleep(0.5) DWIM? Damian Conway
- Re: Why shouldn't sleep(0.5) DWIM? abigail
- Re: Why shouldn't sleep(0.5) DWIM? David L. Nicol
- Re: Why shouldn't sleep(0.5) DWIM? Nathan Wiger
- Re: Why shouldn't sleep(0.5) DWIM? abigail
- Re: Why shouldn't sleep(0.5) DWIM? Stephen P. Potter
- Re: Why shouldn't sleep(0.5) DWIM? James Mastros
- Re: Why shouldn't sleep(0.5) DWIM? John Porter
- Re: Why shouldn't sleep(0.5) DWIM? Bart Lateur
- Re: Why shouldn't sleep(0.5) DWIM? Branden
- Re: Why shouldn't sleep(0.5) DWIM? Bart Lateur
- Re: Why shouldn't sleep(0.5) DWIM? Nicholas Clark
- Re: Why shouldn't sleep(0.5) DWIM? Branden
- Re: Why shouldn't sleep(0.5) DWIM? Simon Cozens
- Re: Why shouldn't sleep(0.5) DWIM? Branden
- Re: Why shouldn't sleep(0.5) DWIM? Andreas J. Koenig
- Re: Why shouldn't sleep(0.5) DWIM? Andy Dougherty
- Re: Why shouldn't sleep(0.5) DWIM? Jarkko Hietaniemi