#!/usr/bin/perl use strict; use CGI; $|=1; my $cgi = CGI::new(); my $time = $cgi->param("time"); my $tmp_path = "/path/to/html/dir/tmp"; # path to temporary html directory my $tmp_url = "http://domain.com/dir/tmp"; # URL to temporary html directory # create tmp file name my $timestamp = time(); my $basefilename = "test_$timestamp"; my $tmp_filename = "${basefilename}_tmp.html"; my $final_filename = "$basefilename.html"; # create meta refresh page open(REFRESH,">$tmp_path/$final_filename"); print REFRESH "\n\n" . "\n\n


This page will refresh every 5 seconds until your results are complete." . "

\n\n\n\n\n"; close(REFRESH); # fork if(my $pid = fork) { ## parent process # send redirect print "Location: $tmp_url/$final_filename\n\n"; } else { ## child process # close STDIN/OUT open(STDIN,"/dev/null"); open(STDOUT,">/dev/null"); # do something that takes a while sleep($time); # create completed page open(FINAL,">$tmp_path/$tmp_filename"); print FINAL "\n\n\n\n


Results Page" . "

\n\n\n\n\n"; close(FINAL); # overwrite meta-refresh page with completed page `mv $tmp_path/$tmp_filename $tmp_path/$final_filename`; } # end if exit(0);