By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

CGI script: redirect a page, then redirect to *another* page.

P: 1
Okay, Here's what I want to do.

I want to write a cgi-script that does something that takes a while to run. While it does that something, it displays content to a page. When it's done doing that something, it loads a new page.

For example:

----------
Expand|Select|Wrap|Line Numbers
  1. $| = 1; #autoflush so the output with go "live" to the page.
  2.  
  3. print "Content-type: text/html\n\n";
  4. print "<h1>Let's count to 100!</h1>\n";
  5. for ($i = 1; $i <= 100; $i++){
  6.      select(undef, undef, undef, .25);#sleep 1/4 second between lines
  7.      print "<b>$i !!!</b><br>\n";
  8. }
  9. select(undef,undef,undef, 1);
  10. print "<h1>Yeah!!</h1>";
  11. select(undef, undef, undef, 2);
  12.  
  13. // a bunch of magic perl code I don't know how to do that will kill the current 
  14. response, and set up a new response and reset STDOUT as though
  15. nothing has been passed yet. //
  16.  
  17. print "Content-type: text/html\n\n";
  18. print "<h1>Wasn't that fun!</h1>";
----------------------------------------------------
If I knew the magic perl, this would:

Display a page that will take 25 seconds to display the numbers 1 to 100 (1/4 second per number) and *then* loads a "new" html page, that says "Wasn't that fun?"

Without the magic perl this, of course, displays the page that takes 25 to "count" to 100, Then prints "Content-type: text/html" and "Wasn't that fun" at the bottom of the page.

Anyone know how/if I can kill STDOUT and "start anew"?
Mar 10 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.