in reply to Flushing stdout

Try one of these:
  1. Use the $| variable, see QandASection: input and output.
  2. Use the IO::Handle module.