I'm in the process of fine tuning my perl server for RioReceivers but could do with some help regarding perl and I'm sure there are some experts here.

When does perl actually output what is specified with a 'print' command?

AFAICT it does not occur immediately, but it also appears not to wait until the script ends. In fact it seems to be quite inconsistent, but maybe that's me.

A perl script of mine that runs from cron and contains 2 consecutive procedures will show in the email (standard) errors from the second procedure BEFORE perl has 'printed' that the first procedure has ended, let alone the second one started. IOW, the perl 'printing' is delayed, but why and by how much?

This is important since I want to 'print' some output for apache to make into a web page, but then to continue with some further processing before the CGI actually ends - I don't want apache to have to wait for the output until the entire process has finished.

Any suggestions?