Home > Archive > PERL Miscellaneous > July 2004 > Another bizzare PerlScript/WSH problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Another bizzare PerlScript/WSH problem
|
|
|
| Hi All,
using a seemingly harmless "sleep" in a simple PerlScript
context virtually freezes the browser:
<HTML>
<HEAD>
<TITLE>Freeze with sleep</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="PerlScript">
while (true) {
$window->document->write("."); # Progress indicator
sleep 10;
}
</SCRIPT>
</BODY>
</HTML>
Again, I am using Windows XP Professional here, IE 6.0 and AS Perl 5.8.0.
Thanks for any hints,
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
| |
| Bob Walton 2004-07-24, 3:56 am |
| corff@cis.fu-berlin.de wrote:
....
> using a seemingly harmless "sleep" in a simple PerlScript
> context virtually freezes the browser:
>
> <HTML>
> <HEAD>
> <TITLE>Freeze with sleep</TITLE>
> </HEAD>
> <BODY>
> <SCRIPT LANGUAGE="PerlScript">
> while (true) {
> $window->document->write("."); # Progress indicator
> sleep 10;
> }
> </SCRIPT>
> </BODY>
> </HTML>
Well, that's about what a script like that should do. Your server is
waiting for the script to finish before closing the output. And your
browser is waiting for the server to close its output before finalizing
its display. What were you expecting this script to do?
....
> Oliver.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
| |
|
| Bob Walton <invalid-email@rochester.rr.com> wrote:
: > <SCRIPT LANGUAGE="PerlScript">
: > while (true) {
: > $window->document->write("."); # Progress indicator
: > sleep 10;
: > }
: > </SCRIPT>
: Well, that's about what a script like that should do. Your server is
: waiting for the script to finish before closing the output. And your
: browser is waiting for the server to close its output before finalizing
: its display. What were you expecting this script to do?
Well, humbly speaking, I expected the script to loop and fill the browser
window with dots, slowly, but steadily. I must confess that I do not feel
perfectly enlightened with regard to the sequence of events:
browser waits for server to close output -> understood so far
but this an only take place after:
server waits for script to finish -> I fail to understand this one.
I've written a few utilities basically using this loop, reading lines from
a file, digesting them in the desired way, and sending them to the browser
from within the while loop via $window->document->write, and they always
worked. Do I have to understand that the browser STARTS building the output
page ONLY after the while loop, reading and processing data activities have
ended?
Somehow I had expected output to start while the while loop is still active.
Thank you very much for further clarification. The finer points of job
control frequently escape my mind, my strength happens to be more in dealing
with foreign language character data.
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
| |
|
| Bob Walton <invalid-email@rochester.rr.com> wrote:
: > <SCRIPT LANGUAGE="PerlScript">
: > while (true) {
: > $window->document->write("."); # Progress indicator
: > sleep 10;
: > }
: > </SCRIPT>
: Well, that's about what a script like that should do. Your server is
: waiting for the script to finish before closing the output. And your
: browser is waiting for the server to close its output before finalizing
: its display. What were you expecting this script to do?
Hi Bob,
In addition to your answer and my previous mail which was, I assume, a bit
naive, I think I get the point. If I replace <SCRIPT>...</SCRIPT> and every-
thing in between by one fictive token, my HTML skeleton will look like this:
<HTML>
<HEAD>
</HEAD>
<BODY>
<Something that is represented by my SCRIPT>
</BODY>
</HTML>
And as long as the "parsing" of the token contents does not finish the
browser will never continue beyond that point. Strictly speaking, this
is not a Perl or PerlScript problem -> hence it is off topic. Sorry!
I had somehow assumed that the PerlScript Perl script keeps running,
while the rest of the HTML page is being built as well. How stupid.
Thanks again,
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
| |
| Jürgen Exner 2004-07-28, 9:00 pm |
| Bob Walton wrote:
> corff@cis.fu-berlin.de wrote:
>
> ...
>
>
> Well, that's about what a script like that should do. Your server is
> waiting for the script to finish before closing the output. And your
> browser is waiting for the server to close its output before
> finalizing its display. What were you expecting this script to do?
Certainly not. This PerlScript is run client side and there is no server
involved..
The script is executed "onload" and with a little bit of experimentation it
becomes quite clear that no content will be displayed by the browser until
the script is finished.
Now, if this is the expected behaviour of "onload"-scripts or a bug in the
PerlScript implementation you probably will have to ask in newsgroup that
knows a good deal more about DHTML.
jue
| |
| Bob Walton 2004-07-28, 9:00 pm |
| Jürgen Exner wrote:
> Bob Walton wrote:
>
....[color=darkred]
>
> Certainly not. This PerlScript is run client side and there is no server
> involved..
You are correct. Sorry for the misinformation. I'll try to stick to
stuff I actually know something about...
....
> jue
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
| |
| Joe Smith 2004-07-28, 9:00 pm |
| corff@cis.fu-berlin.de wrote:
> <SCRIPT LANGUAGE="PerlScript">
> while (true) {
> $window->document->write("."); # Progress indicator
> sleep 10;
> }
> </SCRIPT>
Browser's don't display partial lines; they buffer up HTML data until
there is a line break. Try changing that to write(".<BR>").
-Joe
|
|
|
|
|