Sending a "status"

B

Bill H

Using $|++ I have learned that I can "flush" the print buffer to a
browser while perl is doing things, instead of sending all the html
when it is done. Is there any drawbacks to using this in the real
world that any of you may have encountered?

Basically what I would be doing is sending a status to a client while
the perl scripts are working such as (after sending the html headers
and other stuff):

Saving your data...
Processing your data...
Generating completed pdf...
Complete.

etc...

and then sending the ending html data.

Bill H
 
J

Jürgen Exner

Bill said:
Using $|++ I have learned that I can "flush" the print buffer to a
browser while perl is doing things, instead of sending all the html
when it is done. Is there any drawbacks to using this in the real
world that any of you may have encountered?

Basically what I would be doing is sending a status to a client while
the perl scripts are working such as (after sending the html headers
and other stuff):

Saving your data...
Processing your data...
Generating completed pdf...
Complete.

etc...

and then sending the ending html data.

Not that you question has anything to do with Perl, but you do realize, that
the browser is not obligated to display incomplete HTML pages? Many will
wait until the complete page has been received before beginning to render
it.

jue
 
M

Martijn Lievaart

It is solvable but not for 100% ;-)
At first you must keep in mind that some html tags are displayed after
end tag only. For example you must not put messages into <table>. At
second you must send many (useless) spaces to fill browser buffer.

$|=1;
print "<p>Saving your data...</p>, ' 'x1024; # do something
print "<p>Processing your data......</p>, ' 'x1024;

# do something

This work well (tested) for MSIE5.x and latter and Firefox 2.x and
latter.

To be more exact, some versions of IE don't display anything unless they
have received 256 characters (or the page is complete, obviously). So
send 256 spaces first and then start outputting the rest. No need to send
1024 spaces on every print.

M4
 
M

Martijn Lievaart

Yes, I found this information somewhere too, but in real this is not
true :) Some MSIE (maybe some 6.x) need 512 bytes and some Firefox need
a little more so I send 1024 everytime and this work for most browsers.
All browsers trash redundant spaces and show only one.

Ah, thanks. Sending 256 spaces "worked for me" up to now, but I like to
stay on the safe side an will follow your advice.

M4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top