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

I have a handy CGI script collecting information from users from my site,
and it also prints out a page giving more info.
This is probably a relatively simple answer,
but how do I make the server parse the output for includes?
I have set an apache handler to parse all .html, but it still returns an unparsed page.
Is there something I should change in my script in the "content-type:" line?

Replies are listed 'Best First'.
Re: server-parsed CGI output?
by chip (Curate) on Dec 28, 2001 at 05:09 UTC
    This is an Apache question. Please read your Apache docs.

    If you're willing to let the Perl code do the include processing, however, you may wish to use HTML::Mason or HTML::Template or some other such module.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: server-parsed CGI output?
by cwest (Friar) on Dec 28, 2001 at 05:15 UTC
    I think you're pretty much out of luck there.
    I have done this trick in the past:
    Create a SHTML file that includes your program.
    Make sure all your <form> tags point to the SHTML file, and use GET.
    <html> .... <!--#include virtual="foo.cgi?${QUERY_STRING}" --> .... </html>
    This will ensure that you get the "wrapper" effect from the SHTML file, as well as form processing and/or dynamic output from your CGI program.
    Enjoy!
    --
    Casey
       I am a superhero.
    
Re: server-parsed CGI output?
by IlyaM (Parson) on Dec 28, 2001 at 14:49 UTC
    In Apache 1.3.xx you cannot have stacked handlers. Either you have CGI handler, or you have SSI handler for some file. There is no (easy) way to pass output of CGI script throw SSI processor.

    However there is exist module which can emulate SSI processing: CGI::SSI, . You can use it in your CGI scripts.

    Another option is Apache 2.0.xx which supports stacked handlers.

    Update: And another solution is running your scripts using mod_perl. There exist module Apache::SSIChain which can pass output of your script throw SSI processor (using some black magick I think :). Works only under mod_perl.

    --
    Ilya Martynov (http://martynov.org/)

      I suddenly realized a very simple solution to my simple problem! the "require" command. I should have thought of this before. It's a hassle updating the output of all my CGIs, but if I just call for each CGI to include a list of variables containing my output paramaters, I only have to update one file to change all the CGIs, which was my premise on using SSI in the first place. So, if anyone else is still hunting for an answer, this was mine.