The symptom you describe is not caused by H::T rather by the way the web server process itself runs. If you want to do something time consuming after displaying a web page you need to do some fork magic. Here's an example -
#!/opt/perl/bin/perl $| = 1; $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/etc"; use strict; my ($child, $grandchild); unless ($child = fork) { # This is the child # close STDOUT and fork a grandchild to do the real work; close STDIN; close STDOUT; close STDERR; unless ($grandchild = fork) { # This is the grandchild open OUTFILE, ">>fork.log" || die "Cannot open log file"; my $date = `date`; print OUTFILE "Start: $date"; sleep 20; $date = `date`; print OUTFILE "End : $date"; close OUTFILE; exit 0; } # end grandchild UNLESS loop exit 0; } else { ## This is the parent - Display Processing message ## print "Content-type:text/html\n\nParent leaving\n"; waitpid $child, 0; exit 0; } # end child UNLESS loop You print the output (the web page) in the parent and do the time wasting stuff in the grandchild process. Works every time. Steve Steve Ragan Sr. Internet Developer Internet Services Division Bernard C. Harris Publishing Co., Inc. 2500 Westchester Ave. Purchase, NY 10577 (914) 641-3948 [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of John Sent: Monday, May 10, 2004 11:39 AM To: [EMAIL PROTECTED] Subject: [htmltmpl] Executing code after print $template->output Hi everyone BACKGROUND I'm using H::T with mod_perl and want to run some slow (several seconds) of code at the end of a script, and after the user receives his HTTP response. I have tried doing the following: print $template->output; $r->register_cleanup(\&some_stuff); sub some_stuff() { sleep 10; #for example } Expecting to receive the template page while the sub routine "some_stuff" does its thing. However, H:T seems to wait till "some_stuff" finishes before going to work. AND NOW THE QUESTION(S) So is there any way of getting H::T to get to work before the script calling the ->output method finishes ? What exactly does H::T wait for before swapping the tags anyway ? An alternative (and maybe off topic) question would be, if H::T must wait till the script calling the output method finishes before executing, does anyone know of a way to get the results I am looking for without forking ? Cheers John --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.680 / Virus Database: 442 - Release Date: 09/05/2004 ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users