in reply to sleep problem !

You forgot to unbuffer the output filehandle. Add $| = 1; before printing.