Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Printing to the browser FIRST.

瀏覽次數:8 次
跳到第一則未讀訊息

turtlep...@yahoo.com

未讀,
2006年7月7日 上午9:35:362006/7/7
收件者:
passme

Hi folks. I hope someone can help me. I've looked in all my Perl books
and online and can't find a solution. I have a script in which
everything in the script works fine except about half the time, the
server waits until its completely finished to return any results to the
browser. Ideally, I'd like the script to return something to the
browser first just to let the user know everything is working fine such
as, "Doing something for you, please be patient...". Then, only after
it has returned something to the browser, continue with it's other
duties. And finally, print "Done!" when finished.

Does anyone know how to tell Perl to issue the first couple print lines
to the browser first before continuing with other back end
instructions? It does it now, but only about half the time. (Not very
reliable.) See my sample code below for illustration.

Please post to group. Do not reply to my email address. Thanks!
Craig

----------------------------------------------
print "Content-Type: text/html\n\n";
print "Print something first to browser...please be patient, etc...\n";

# Other duties...
use LWP::UserAgent;
my $res = $ua->post($url,\%form);
# etc...

print "Done!\n";
----------------------------------------------


--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html

Steven Saunderson

未讀,
2006年7月7日 上午9:49:092006/7/7
收件者:
On Fri, 7 Jul 2006 07:35:36 CST, turtlep...@yahoo.com wrote:

> Hi folks. I hope someone can help me. I've looked in all my Perl books
> and online and can't find a solution. I have a script in which
> everything in the script works fine except about half the time, the
> server waits until its completely finished to return any results to the
> browser. Ideally, I'd like the script to return something to the
> browser first just to let the user know everything is working fine such
> as, "Doing something for you, please be patient...". Then, only after
> it has returned something to the browser, continue with it's other
> duties. And finally, print "Done!" when finished.

$| = 1; # disable output buffering

Put the above line at the start of the script.
Does this help ?

--
Steven

Sherm Pendley

未讀,
2006年7月7日 上午10:53:132006/7/7
收件者:
turtlep...@yahoo.com writes:

> Does anyone know how to tell Perl to issue the first couple print lines
> to the browser first before continuing with other back end
> instructions?

Try disabling line buffering - have a look at $| in "perldoc perlvar".

$| = 1;

> Please post to group. Do not reply to my email address.

That's standard usenet practice anyway. :-)

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

turtlep...@yahoo.com

未讀,
2006年7月7日 晚上7:48:082006/7/7
收件者:
Thank you! Yes that fixed it.

Craig

0 則新訊息