The way that I always approach this is to create all CGI scripts that need to be called from SSI as modules which export a function which produces the necessary HTML output. I then create a wrapper script which just loads the module, prints a CGI header and calls the function. I can then call this script in an SSI call. When I need to use the same functionality within a dynamically created page I can use the module and call the function.
--
<http://www.dave.org.uk>
European Perl Conference - Sept 22/24 2000
<http://www.yapc.org/Europe/>
| [reply] |
This question depends on so many things:
- What webserver are you using?
- Did you write the SSI programs yourself? Do you have access to the sourcecode? Are they written in perl?
- Do you have mod_perl?
If this were my project runing under Apache w/ mod_perl
and the SSI scripts were programs that I had written;
I would convert all the SSI's to perl modules and
call them via mod_perl from the new .cgi programs. | [reply] |
OK, thanks guys, but I need to refine my question a little:
I am running apache, but I'm not sure if it supports mod_perl, since I am not administrating the webserver at my university (and I think that I don't really need to know to obtain what I'm looking for).
Creating a module is something that I could do, but remember that laziness is what makes a programmer (maybe not a Perl Monk?), so my question was more something like:
What is the best way, when parsing my template html files (which contain SSI exec calls) to produce the same effect as a real SSI call, without having to change anything to the SSI scripts.
The scripts are written in Perl, of course, so I have access to the source code. Rewriting them as a module would not be a big hassle, but simplicity and ease are good virtues (wouldn't that be cool if I could redistribute my SSI scripts for somebody who wants to use them as real SSIs?). | [reply] |
You could do the backtick way (as davorg mentioned), but if you are using mod_perl, you may want to look at Apache::SSI. This may (or may not) do what you want with minimal changes. But, if you are changing the whole way your system works (static to dynamic) you may want to not put a bandaid on it and simply redo it all the right way. What is the right way? Well, that is for you to decide. Maybe HTML::Mason is, or Embperl, etc...
Cheers,
KM
| [reply] |
| [reply] |
I just had an other idea: what about just reading the file that contains the SSI perl script in an array, (and yes, remove the content-type output line), join() the array into a single string, and then do an eval() on that? | [reply] |