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

Hey monks,

I need to write a CGI program that flashes a message on the screen, while it does a big time-consuming process.

Prob is that the browser hangs, while the process is going, then flashes the message when it's all ended.

How can I get the code to flash the message, stop HTTP, and then continue with the big process?

I tried closing STDOUT after flashing the message, but that tends to terminate everything (which shouldnt, since after all I am closing standard output, but shouldnt close the program down.

Thanks!

Here's my code:

sub logmining'start { my ($xtract); my ($userEmail, $head, $foot, $myFile); my (@range); $head = &logmining'PrintHeader (); $foot = &logmining'PrintFooter (); # FLASH MESSAGE: print "$head<tr bgcolor=\"#EBEBEB\"><td><span class=\"texthead\">T +he data is now being processed. Once it is done, you will get an ema +il with all the results that will be sent to $userEmail.</span></td>< +/tr>$foot"; print STDERR "\n\n===== START =====\n"; # Get range of dates @range = &logmining'getDateRange (); foreach $myFile (@range) { # TIME CONSUMING PROCESS: print STDERR "gunzip -c $myFile | grep \"01225322|2199592\"\n\ +n"; $xtract = `gunzip -c $myFile | egrep "01225322|2199592"`; last; # JUST RUN ONE FOR NOW PLEASE! } print STDERR "XTRACT:\n$xtract\n\n"; exit (1);

Robert

Replies are listed 'Best First'.
Re: Why does close(STDOUT) terminate my program?
by merlyn (Sage) on Jul 27, 2005 at 16:35 UTC