in reply to print misbehaves

You may be suffering from buffering.

Also see perlfaq5

If that's the case, then you need to set the autoflush flag. This is generally achieved by just doing $|++;
However, if you are printing to a filehandle then you may need to select that filehandle first. See the links above for a more in-depth discussion.

Hope this helps,
Darren