in reply to flushing CGI output

Your problem is probably that your web-server is caching (buffering) the results for you... Check the CGI man-page for info on NPH scripts.

I know using CGI's NPH features got my script to work 'unbuffered' when using Apache.

The 'nice' way to do it though would probably be to log your status to your apache error log (STDERR from a CGI perl), and keep track of your script through that channel. You should't debug in your browser window...

Splitting your code into 'non-web-specific' parts that show optional debug info on STDERR also makes it more re-usable, so that you could easily convert your web-chore into for instance a daily cron-chore... Your CGI-script should merely be a wrapper around environment-independent modules/snippets/codelets or even nodelets should it come that far... :)