I have this Perl script sitting in the cgi-bin folder of my Apache server:
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
print \"Content-type: text/ht
Randal Schwartz shows a better way in Watching long processes through CGI.
That said, lying about the content type will not help. The following script does exactly what you seem to want it to do on Windows XP with Apache 2.2 (in that it takes ten seconds for the last line of output to appear):
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:cgi);
print header('text/plain');
$| = 1;
print "Job started\n";
for ( 1 .. 10 ) {
print "$_\n";
sleep 1;
}
Now, if you are sending HTML, you cannot avoid the fact that most browsers will wait until they what they believe is enough of the page to begin rendering.