http://www.perlmonks.org?node_id=494051


in reply to sleep problem !

Your standard output needs to be unbuffered.

Add this line before your loop:

$|++;

And you should get what you want.

See Suffering from buffering (off site) for a thorough explanation.