in reply to Re: Sending html content to the browser as the script runs
in thread Sending html content to the browser as the script runs

Through my browser, it seems to dump to the client all at one time still at the end. Would you guys mind scanning my code real quick and see if you notice anything suspicious? Should I be putting more in the header()?
thanks,
PJM
#!/usr/local/bin/perl #script: nph-test_script_jmj.cgi use strict; use CGI qw(:standard -nph); $| = 1; ################### MAIN ########## CGI->nph(1); my $cgi = CGI->new(); print $cgi->header(-nph=>1); html_1(); print "my second is: " . mytime() . "<br>\n"; sleep 3; print "my second is: " . mytime() . "<br>\n"; html_2(); ############################################ sub html_1 { print "\n"; print "processing file<br>\n"; } sub html_2 { print "\n"; print "done processing file<br>\n"; } sub mytime { my ($sec) = localtime; return $sec; }

Replies are listed 'Best First'.
Re^3: Sending html content to the browser as the script runs
by jdtoronto (Prior) on Aug 03, 2006 at 12:55 UTC
    I ran your script as is and got:
    processing file my second is: 42 my second is: 45 done processing file
    What server software are you using? Not all servers support NPH scripts.

    jdtoronto

      Apache 1.3

      When you ran the script, did it print the first two lines and then hang for 3seconds before printing the third and fourth lines?

      For me, it just dumped it all at once.

      -josh