in reply to Embedded redirection

You probably want to take advantage of a standard HTTP redirect. Using <meta> tags in this fashion is highly questionable. Fortunately, CGI.pm makes this easy.
use CGI ':standard'; # do processing print redirect('http://example.com/');
At this point you may just have to close STDOUT for the server to notice the response is concluded. Otherwise, you can fork your processing into the background and have the parent exit normally.
my $pid = fork; exit if $pid; die "fork: $!" unless defined $pid; # or maybe just warn # continue processing

Replies are listed 'Best First'.
Re: Re: Embedded redirection
by Anonymous Monk on Jan 13, 2001 at 05:26 UTC
    Using CGI.pm to do redirection works fine. However, when I close STDOUT, the user is immediately redirected but the rest of my script no longer executes defeating the purpose of trying to redirect early. Is forking the only way to make this work?
      I don't know; I'd have to experiment. The server may be killing you. Someone else may have better information, but I would try ignoring some signals. I suspect the server would send a HUP in a case like this, but it might be more aggressive.
      $SIG{HUP} = $SIG{INT} = $SIG{TERM} = 'IGNORE';
      Since that makes it a bit harder to kill a run-away process, you might want to set a timeout so your script commits suicide after a reasonable amount of time.
      $SIG{ALRM} = sub { die "$$ timed out" }; alarm 30;
        This code finally worked.
        my $result= new CGI; print $result->redirect("http://www.example.com"); close STDOUT; my $pid = fork; exit if $pid; die "fork: $!" unless defined $pid;
        However, is this the most efficient way of doing things? Is it going to clog the system up if the script is accessed very freqeuntly? Thanks.