in reply to Progress Bar controlled via Perl

While perhaps not as robust as merlyn's method, there's a much simpler way to do it. Just turn on autoflush ($| = 1) and have your script start outputting to the browser right away. Then update your progress bar every so often while your script runs. Here's a simple example:

#!perl -w use strict; use CGI; $| = 1; # turn on autoflush print CGI->header; print "Progress: "; for (1..10) { print '.'; sleep 2; } print "\n<br><br>Done!";

-b

Replies are listed 'Best First'.
Re^2: Progress Bar controlled via Perl
by edan (Curate) on Aug 22, 2004 at 13:31 UTC

    This method does not always work. For instance, I have been working on a Web App which did something similar. We recently changed the system architecture so that the CGI now sits behind an Apache Reverse Proxy. I cannot get the Reverse Proxy to unbuffer, so this method no longer works. I wonder if a regular Forward Proxy might not do the same thing - probably depends on the proxy server. Just thought I'd mention it.

    --
    edan