in reply to Force Browser to Render Partial Page

Be sure to unbuffer STDOUT with

$|++;
at the start of your script.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Replies are listed 'Best First'.
Re: Re: Force Browser to Render Partial Page
by Anonymous Monk on Aug 28, 2003 at 05:02 UTC
    When STDOUT is redirected to the browswer with CGI is it still buffered? I rarely see CGI scripts starting like that, which is why I ask.

      Consider this code:

      #!/usr/bin/perl -w $|++; use CGI; $q = new CGI; print $q->header(), $q->start_html(), "before wait<br /><br/>"; sleep 5; print "after wait\n\n\n", $q->end_html;

      As shown, my browser (Mozilla 1.4) renders "before wait", then several seconds later, "after wait" appears.

      If I comment out the $|++; then all of it shows up in the browser at the same time.

      --Bob Niederman, http://bob-n.com

      All code given here is UNTESTED unless otherwise stated.