On 6 Dec 1999, Martin Holz wrote:

> "Ken Y. Clark" <[EMAIL PROTECTED]> writes:
> 
> > On 6 Dec 1999, Martin Holz wrote:
> > 
> > > 
> > > I am trying to catch the output of a CGI
> > > script and put the body of the generated 
> > > HTML page in a template.
> > > 
> > > Works fine unless the CGI script calls CGI::header.
> > > If the scripts calls CGI::header, two headers
> > > are sent, the first by Apache::Registry/CGI.pm,
> > > the second by my own content handler.
> > >  
> > > Aparently CGI::header does not send its output
> > > to STDOUT, if it runs under Apache::Registry.
> > > 
> > > How can I intercept the first header?
> [...]
> 
> > any reason why you can't use HTML::Template?  it works beautifully for me,
> > both under a CGI/Registry format as well as mod_perl modules.
> > 
> > ky
> 
> I use HTML::Embperl::Execute inside a mod_perl handler to
> process the template and it works fine with static files.
> The trouble starts when I want to embed the output of 
> a CGI script into a template.
> 
> I could easly solve the problem by modifing the CGI script,
> but I don't want to change it, because I didn't wrote it.
> 
> Problem is both the CGI script and the my mod_perl-handler send 
> a header.
> 
>       Martin Holz

my experience w/something like the following:

my $subr = $r->lookup_uri('/foo.html');
$subr->run;

is that you have no control over what goes to STDOUT after you say
"$subr->run".  i would imagine you'll have the same problem when you run
your CGI script.  i assume you want to do something like read the output
of the CGI into a string or array and then delete the header lines?  can
you do something like :

my $result = `/usr/local/bin/perl /my/very/good/path/foo.cgi`;
$result =~ s/bad-header//;
$r->content_type("text/html");
$r->send_http_header;
$r->print($myheader);
$r->print($result);
$r->print($myfooter);

???

i'm not sure this is such a good idea.  if you could easily "solve the
problem by modifing the CGI script," i would probably recommend doing just
that.  

hth,

ky

Reply via email to