Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing to the browser FIRST.

8 views
Skip to first unread message

turtlep...@yahoo.com

unread,
Jul 7, 2006, 9:35:36 AM7/7/06
to
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

unread,
Jul 7, 2006, 9:49:09 AM7/7/06
to
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

unread,
Jul 7, 2006, 10:53:13 AM7/7/06
to
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

unread,
Jul 7, 2006, 7:48:08 PM7/7/06
to
Thank you! Yes that fixed it.

Craig

0 new messages