Re: Problems flushing my buffer! (perl)

On Oct 3, 1:30 pm, Jürgen Exner <jurge...@xxxxxxxxxxx> wrote:
Nigel <ni...@xxxxxxxxxxxxx> wrote:
Hi there,

I hope you can help - I'm writing a perl program and I want it report
back to the browser
on its progress. I read the perl faq and saw that by setting $| true
the buffer would be
flushed each time I printed instead of waiting until the program
terminates. But I can't
get it to work.

I'm expecting the web page to say that it's on the job, then every
second (for 10 seconds) to say Please Wait and then at the end to say
it's finished. But what happens is I wait ten seconds for a response
and the whole lot appears at once. Any advice would be VERY welcome.

The whole lot appears at once _WHERE_?

Run your sample program from the command line and you will notice,that
there is the desired one second pause between each  "Please wait!<br

Of course your web server typically will not transmit the HTTP response
in such small chuncks but wait until it recieves EOF. And a web browser
may not display any HTML-page until it has been downloaded completely.
But neither of these has _ANYTHING_ to do with Perl but would happen
exactly the same way no matter in which programming language the CGI
program was written in.


To clarify - it all appears at once in my web browser.

So it seems I must rephrase my question and perhaps address it to a
different Group as apparently the problem isn't with my Perl as
such...but I am writing this in Perl so I guess I still have a Perl
related question: Is it possible to achieve what I want i.e. to
request my perl program from my browser and have the program tell me
the progress it is making from time to time and have that appear in my
browser in real time? My impression from what I read in the faq (and
elsewhere) was that such a thing IS possible, but perhaps I've
misunderstood. In the worked examples I saw, they talked about
'Forking' - which I understand to mean that one part of the program
responds to the browser, whilst another part carries on with the
processing. I have to say I couldn't really get my head around the
examples I saw which is why I was trying to start off simple! Thanks
for the response anyway.

Relevant Pages

  • Re: Why why why? (Was: Re: Vertical alignment of text within a DIV)
    ... Sadly CSS2 does not offer a good method for creating layouts ... anything else a browser adds to the base web experience. ... successfully been achieved with the likes of Java and Perl. ... the same would not of been a far better solution for HTML, XML, CSS, ...
  • Re: web pages
    ... This code opens internet explorer and displays web page cannnot be found. ... Start a browser, such as Internet Explorer, and get it to fetch web ... None of the content will end up in your Perl ... You can write a Perl program to act like a browser by programming it ...
  • Re: Browser-specific perl error (taint mode)
    ... This depends on on alot of factors, few of which you are sharing.Generally, perl ... errors should not come through to the browser. ... It is possible that your server can not negotiate a secure protocol with IE. ... You are using user-provided data as a parameter to a shell command, ...
  • Re: Slide show: this should be fairly straightforward - a what language to use question
    ... You should really learn some HTML before ... Perl is a general purpose programming language that can be used to write ... server side programs that can be used through CGI. ... If it's just a browser he needs, ...
    ... > file exactly the way a browser would render it? ... Launch the browser to the requested URL from a perl script. ... Your browser and whatever it displays are an X11 window within your ... Use scriptlets supplied with your window manager that ...