in reply to problem with delay(my little code)

You are Suffering From Buffering. In short, adding the following line after your use statements will remove the problem:

$|++;