Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Show information before end of script

by schweini (Friar)
on Sep 15, 2005 at 23:46 UTC ( [id://492469] : note . print w/replies, xml ) Need Help??

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.