Reg: Perl CGI script Autoupdate with New Data

2020-02-15 07:12发布

Hi This script is taking 3*2 secs time and then printing the output in the browser at once, help re

#!C:/perl/bin/perl.exe
use warnings;
use strict;
use CGI;

my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html("First");
print $cgi->h1("First");
sleep(2);
print $cgi->h1("Second");
sleep(2);
print $cgi->h1("Third");
print $cgi->end_html();

标签: perl
1条回答
Lonely孤独者°
2楼-- · 2020-02-15 07:38

You can set $| = 1; to flush the output buffer with each print, but it looks like Apache will wait for the script to finish running before returning anything, so you might need to move your sleep logic into client side JavaScript.

查看更多
登录 后发表回答