Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:11:01+00:00 2026-06-04T15:11:01+00:00

I’ve written a very small html page for IE that uses client-side PerlScript. In

  • 0

I’ve written a very small html page for IE that uses client-side PerlScript. In the script, I launch a separate process which creates a TCP socket. After launching the process, I start a listener which appends HTML to the end of a div as lines are read, additionally for debugging, I added alerts as each line is read.

The problem is that the alerts hit spot on as lines are read, but the HTML doesn’t update until the process has finished. Why is that? Is there a way to force the page to render so that I can get the same behavior?

Here’s the page:

<html>
    <head>
        <title>Message Test</title>
        <script language=perlscript>
            use util;
            use Win32::Process;

            my $alreadyrunflag = 0;

            sub _write {
                $window->document->body->insertAdjacentHTML("beforeEnd", $_[0]);
            }

            sub go {
                _write("starting!<br/>");

                my $port = 12345;
                #//system("start /b /NORMAL perl C:/development/plslog/clitest2.pl $port");
                Win32::Process::Create(my $Proc, "C:/perl/bin/perl.exe", "perl clitest2.pl 12345", 1, CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, "C:/development/plslog");
                $window->alert("Hi! started!");

                if (defined (my $INPUT = util::CreateClient($port))) {
                    while(defined (my $line = <$INPUT>)) {
                       _write($line);
                        sleep(3);
                    }
               }

               _write("ending!");
            }

            $window->setTimeout("go()",0);
        </script>
    </head>
    <body>
        <div id="content"></div>
    </body>
</html>

I have looked at on-line documentation for PerlScript which is incredibly sparse. I’m looking for hints at how to command IE to fire page renders, respond to these html insertions… etc.

In researching this, I have found that I can get it to render as the lines are read if instead of onload, I use an onclick on the div. Perhaps I’m not using the right event and the page isn’t fully rendered before the subroutine is fired? I’m very frustrated with IE here (v. 9).

And yes, when I use this in a command line situation, everything fires as expected. The CreateServer/CreateClient are just wrappers around IO::Socket::INET for client and server.

UPDATE (based @Oleg V. Volkov’s answer):

I modified go and added a _read() function that reads a line, then passes control back to the browser to render. Seems to do an ok job.

sub _read() {
  my $port = shift;
  $INPUT = util::CreateClient($port) if ! $INPUT;
  if (defined (my $line = <$INPUT>)) {
    _write($line);
    $window->setTimeout("_read($port)", 0);
  }
  else {
    _write("Fin!");
  }
}
sub go() {
  _write("starting!<br/>");
  my $port = 12345;
  Win32::Process::Create(my $Proc, "C:/perl/bin/perl.exe", "perl clitest2.pl $port", 1, CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, "C:/development/plslog");
  $window->alert("Hi! started!");
  $window->setTimeout("_read($port)", 0);
}

That seems to get near real-time updates.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:11:02+00:00Added an answer on June 4, 2026 at 3:11 pm

    Most (if not all) browsers do not redraw page until you return from hosted script process. They can reflow internal representation of data on some operations, but still won’t spend time redrawing it until you’ve returned control. To allow browser to redraw, you should break your task into steps and yield once in a while by scheduling next step with setTimeout and returning from your script.

    In your particular case, replacing sleep(3), where you do nothing anyway, with scheduling of next loop iteration to happen 3 seconds later, seems like the best way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.