CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Show before timer

 



fds
Novice

Apr 9, 2012, 11:11 AM

Post #1 of 5 (8275 views)
Show before timer Can't Post

Hi, this may sound a bit trivial, but I have a timer and want some sort of note that it is running.

I have tried as shown, but the "Processing" bit will not show until it is all done. The "Finished" bit is working like it should.

It works on a Refresh, but that's not what I want to happen.

How do I make the "Processing" show first?

Code
use strict; 
use warnings;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print "Content-type: text/html\n\n";

tiMer();
sub tiMer {
print qq ~Processing - want to show before and during timer run (but it doesn't)~;
dodelay();
print qq ~<br><br>Finished - this shows okay~;
exit(0);
}

sub dodelay {
$| = 1;
my $sec = time();
while (time()-$sec < 3){}
}

----------------------------------------------
fdsaadsfdsaf

(This post was edited by Ted on Apr 9, 2012, 11:49 AM)


wickedxter
User

Apr 12, 2012, 5:09 PM

Post #2 of 5 (7874 views)
Re: [Ted] Show before timer [In reply to] Can't Post

put $| = 1; under the she-bang #! so its seen first and not in the sub dodelay


fds
Novice

Apr 13, 2012, 2:26 AM

Post #3 of 5 (7841 views)
Re: [wickedxter] Show before timer [In reply to] Can't Post

Tried that on local testbed and live, didn't work.

Attempted it at various other locations, same result.

The refresh worked, but initial load of the script didn't - both lines came up at the same time, after the delay
----------------------------------------------
fdsaadsfdsaf

(This post was edited by Ted on Apr 13, 2012, 2:27 AM)


FishMonger
Veteran / Moderator

Apr 13, 2012, 6:32 AM

Post #4 of 5 (7832 views)
Re: [Ted] Show before timer [In reply to] Can't Post

This works correctly for me.

Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

$| = 1;
print "Content-type: text/html\n\n";
warningsToBrowser(1);

tiMer();


sub tiMer {
print qq ~Processing - want to show before and during timer run ~;
dodelay();
print qq ~<br><br>Finished - this shows okay~;
exit(0);
}

sub dodelay {
my $sec = time();
while (time()-$sec < 3){}
}



fds
Novice

Apr 14, 2012, 10:37 AM

Post #5 of 5 (7771 views)
Re: [FishMonger] Show before timer [In reply to] Can't Post

Thanks FishMonger - Ted
----------------------------------------------
fdsaadsfdsaf

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives