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

Fellow monks I question on the recommended way of calling mod_perl scripts from an Server Side Include HTML page on Apache (1.3+) server.

My company's website has a number of Html pages created by our graphics designers. We are already using Server Side Includes to add in standard headers and footers. I am working on adding in capability to dynamically generate images that will be shown on some of these pages.

I am not too worried about writting the script itself, but I not very sure about to call the script from SSI tags.

Some research showed following three options:

  1. using <!--#include virtual=
  2. using <!--#include exec=
  3. using <!--#include perl=

Option 1 (virtual):

With this it looks like I have to have the mod_perl script accessible externally for it work. ie. instead of the script being accessible only from SSI tags, Apache permissons have to be setup so that the script could be accessed directrly. I tried adding "deny from all" to the directory that holds the script but then the script could not be called even from SSI.

Option 2 (exec):

Does not allow me to pass any parameters to the script. I need to be able to pass some configuration parameters.

Option 3 (perl):

I only found hints about this option, I could not find much information about it. I Apparently need to set PERL_SSI to 1 while building mod_perl. Not sure if this is a good idea.

Being new to mod_perl developement, I would appreciate any insight into which is the recommended way and if there is a way around the issue with option 1.


Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd

Replies are listed 'Best First'.
Re: calling mod_perl script from SSI page
by cees (Curate) on Feb 10, 2003 at 02:09 UTC

    Have a look at the Apache::SSI module. This is a complete perl re-implementation of the mod_include Apache module, and is most likely what you mean by "Options 3".

    If you subclass it, Apache::SSI will allow you to call your own perl functions directly from the HTML file using ssi tags. You can pass it any number of parameters as well (it even lets you pass a hash to your functions if you like).

Re: calling mod_perl script from SSI page
by data64 (Chaplain) on Feb 10, 2003 at 04:17 UTC

    Option3 should be <!--#perl sub=

    I found more information in the eagle book.


    Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd

Re: calling mod_perl script from SSI page
by perrin (Chancellor) on Feb 10, 2003 at 15:34 UTC
    Option 1 or 3 are both good. Option 3 lets you call a Perl sub directly. Option works like calling a CGI, but is faster because mod_perl handles it instead. You can prevent outsiders from calling by having the script check whether or not the current request is a subrequest and exit if it is not.