Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

cgi write then rewrite

by whaled (Initiate)
on Aug 12, 2004 at 13:08 UTC ( [id://382224]=perlquestion: print w/replies, xml ) Need Help??

whaled has asked for the wisdom of the Perl Monks concerning the following question:

I would in cgi to have a perl program write a html script and with a sleep command in the perl code after the html is written to wait then rewrite another html script out to cgi screen. I know I could write a html out with a javascript timer to after a time bring up the second html screen. But in this case the perl cgi program i want to be one controling how long the wait is before the second html screen replaces the first. Right now the second screen just show under the first one the browser instead of replacing it. ? Can this be done and if so how do i get the second to replace the first

Replies are listed 'Best First'.
Re: cgi write then rewrite
by tstock (Curate) on Aug 12, 2004 at 13:23 UTC
    What you want to be searching for is non-parsed headers (NPH), to keep a script running and replacing the content on the browser by a push method.

    using CGI.pm, I found this example:
    #!/usr/local/bin/perl use CGI qw/:push -nph/; $| = 1; print multipart_init(-boundary=>'----here we go!'); foreach (0 .. 4) { print multipart_start(-type=>'text/plain'), "The current time is ",scalar(localtime),"\n"; if ($_ < 4) { print multipart_end; } else { print multipart_final; } sleep 1; }

    Update: added code example

    Tiago
Re: cgi write then rewrite
by Arunbear (Prior) on Aug 12, 2004 at 13:29 UTC
    One thing you can do to is to put in the first html page some javascript code that (after a timeout) redirects to a cgi script that will produce the second page.

      Why do you need javascript, or CGI for that matter? The following HTML in the <HEAD> element should cause the page to refresh itself every 5 seconds (assuming the page is located at /my.htm).

      <META HTTP-EQUIV="REFRESH" CONTENT="5; URL=/my.htm">
      --
      edan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://382224]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found