in reply to $|=1;
It unbuffers the current output stream, so anything you write "appears as soon as possible". Look in perlvar. Also check out the I/O section in the Tutorials here.