http://www.perlmonks.org?node_id=492469


in reply to Show information before end of script

what i do in long report-generating scripts is to send a
<script> updateProgressbar( $percentCompleted ) </script>

to the browser from inside the loop that's doing the computation. Obviously, i define function updateProgressbar(percent) in some globally included .js file.
Works great for me, but just be careful not to send something like this on every iteration of a fast-iterating loop, since you could easily clog even broadband connections with millions of these instructions. i usually do something like
&printProgessJavascript( %percent ) if ($i++ % 1000 == 0);

on the perl side.