How can I sleep() or alarm() for under a second?

If you want finer granularity than the 1 second that the sleep function provides, the easiest way is to use the select function as documented in select. If your system has itimers and syscall support, you can check out the old example in CPAN/doc/misc/ancient/tutorial/eg/itimers.pl .