Another bizzare PerlScript/WSH problem

G

Guest

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.
 
B

Bob Walton

(e-mail address removed)-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?

....
 
G

Guest

: > <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.
 
G

Guest

: > <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.
 
J

Jürgen Exner

Bob said:
(e-mail address removed)-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
 
B

Bob Walton

Jürgen Exner said:
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...

....
 
J

Joe Smith

<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
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top