i.e.
print qq~ <html><head>...</head><body>...initial template stuff... ~q;
then some code doing some stuff;
print qq~ ...latter template stuff...</body></html> ~;
What I want is for the CGI / Perl scripts to just call the shtml include files, instead of duplicating them. It's all about efficiency and less work when updating things.
My question is: how do I successfully do this?
My attempts haven't worked, and a Google search shows I probably need to install some updates to Perl / Apache. I'm willing to do this, but would rather ensure there isn't a simpler way, first.
[httpd.apache.org...]
Thanks, by the way, for that documentation. It was enlightening.
You can't get SSI to work on pages generated from PERL scripts because Apache purposefully ignores it.
If your page is not time/user sensitive one quick solution is to modify the PERL script to write the page to disk and then print "Location: [domain.com...] to switch over to the page in which case the SSI will work.
Another option is to invert the SSI and HTML by manually creating an HTML page with the SSI coded inline and then call the PERL script inline with an SSI virtual:
<!--#include virtual="/cgi-bin/myscript.cgi" -->
Yet another option (mentioned by KevinADC above) is to open/read/print the SSI file inline as you generate your dynamic page, but SSI commands don't translate 100% equivalent to PERL commands so they may need additional processing.
The viability of these options depends on what you're script is actually doing but either way, it's probably going to be a major bummer.
I struggled with trying to figure out why for 6 months before I stumbled on that doc and found out that it just can't be done.
One thing I've noticed: when generating a dynamic page like this, it must be done just right, else I get the "malformed/bad header" error. Simply having it say
print qq~ <html><head><title>Hi</title></head><body> ~;
...
print qq~ </body></html> ~; just doesn't work at all. What does work, however, is
print qq~
<html>
<head>
<title>Hi</title>
</head>
<body>
~;
...
print qq~
</body>
</html>
~; I don't quite know why, but it seems to matter. Other such tiny seeming-trivialities also seem to affect whether it works or not. Live and learn ...
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print qq~ <html><head><title>Hi</title></head><body> ~;
print qq~ </body></html> ~;
exit;
I looked at the code for CGI:SSI and noticed that it also needs additional modules (as reported in the previous post).
Assuming that CGI::SSI actually IS installed, I suspect that at least one of the modules it tries to use is not installed but I'd like to know exactly which one(s) before I just send the entire list to my host.
I keep getting a 500 error and I can't determine where the fault is because Carp isn't catching it.
If I comment out the use CGI::SSI line the script runs fine.
You can see (a few posts back) that the script is basically just a "Hello World" with some additional uses included.
Why doesn't Carp catch the 500 error to help me find out which module isn't installed (if that's even it)?
[scriptsolutions.com...]