本文介绍了Reg:Perl CGI 脚本自动更新新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个脚本需要 3*2 秒的时间,然后立即在浏览器中打印输出,帮助重新

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();

推荐答案

您可以设置$|= 1; 每次打印都会刷新输出缓冲区,但看起来 Apache 将等待脚本在返回任何内容之前完成运行,因此您可能需要将睡眠逻辑移动到客户端 JavaScript 中.

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.

这篇关于Reg:Perl CGI 脚本自动更新新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 03:29