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

I'm trying to print out a page in HTML via my CGI script.
<!--#exec cgi="catdisplay.pl"-->
The above is nested inside a herdoc statement and in the source code of the browser, it shows that line. It never executes, it just appears as an HTML comment in the source code. I know this catdisplay.pl script is in the same directory as the script that's calling it.

Anyone know why it's not working?

Replies are listed 'Best First'.
Re: exec CGI
by derby (Abbot) on Jun 07, 2008 at 01:27 UTC
    You appear to mixing up apache's Server Side Include's with CGI. If you're executing a CGI to generate the heredoc, why not just execute the catdisplay.pl within the cgi script?
    -derby
Re: exec CGI
by moritz (Cardinal) on Jun 07, 2008 at 07:32 UTC
    It probably doesn't work because your server isn't configured to process SSI directives in script output.

    If your first CGI script also ends in .pl and you have at least Apache 2.0 (Apache 1.3 can't do that IIRC) you can add this line to your server config or .htaccess file:

    AddOutputFilter INCLUDES .pl

    Then it should work. But beware of infinite recursion through mutual inclusion of scripts, i.e. when a.pl includes b.pl and the other way round.