The thing that works best for me is to use an Apache::SSI object myself
rather than using any kind of chaining.
my $ssi = Apache::SSI->new($text, $r);
print $q->header; # send the HTTP header
$ssi->output();
Or you can capture the output instead of just sending it, like this:
my $ssi = Apache::SSI->new($text, $r);
my $result = $ssi->get_output();
I actually do this with a customized subclass that implements some
site-specific SSI directives. I'm calling it from within a custom
handler, and not inside any kind of Registry or PerlRun script. Works
perfectly for me. YMMV.
- Perrin
Christopher Hicks wrote:
>
> I've used the lines below and the various other provided incantations for
> using Apache::SSI or Apache::SSIChain.
>
> PerlModule Apache::SSIChain
> PerlModule Apache::Filter
> PerlModule Apache::SSI
> PerlModule Apache::OutputChain
> Alias /ssiperl/ /www/perl/ssibin/
> <Location /ssiperl>
> SetHandler perl-script
> # PerlSendHeader On
> PerlSetVar Filter On
> # PerlHandler Apache::OutputChain Apache::SSIChain Apache::Registry
> # PerlHandler Apache::SSIChain Apache::Registry
> PerlHandler Apache::Registry Apache::SSI
> Options +ExecCGI
> </Location>
>
> The SSI's get included, but they're all at the top of the file. Both of
> the PerlHandler lines commented out above have SSIChain as the last thing
> which is what the docs say to do. But the includes still get included
> before the rest of the file.
>
> I've scoured the modperl archives. I've read through the source and
> documentation to Apache::SSI*. Does anyone have any ideas?
>
> My workaround:
>
> sub processSSI {
> my ($text,$r) = @_;
>
> my @lines = split(/\n/,$text);
>
> my ($line,@el,$command,$key,$val,%param);
>
> foreach $line (@lines) {
> if ($line =~ /<!--#(.*)-->/) {
> @el = split(/\s+/,$1);
> $command = lc(shift(@el));
> foreach (@el) {
> ($key,$val) = split(/=/);
> $key = lc($key); # lower case key
>
> # strip double quotes if they're there
> # and balanced
> if (substr($val,0,1) eq '"') {
> if (substr($val,-1,1) eq '"') {
> chop($val);
> substr($val,0,1) = '';
> }
> }
> $param{$key}=$val;
> }
> if ($command eq "include") {
> if (defined( $param{'virtual'} )) {
> Apache::Include->virtual($param{'virtual'});
> }
> }
> } else {
> print $line, "\n";
> }
> }
> }
>
> This handles my needs. It is a disadvantage to be stuck with putting
> anything that isn't an "include virtual" into a file which is then called
> via an "include virtual". But at least it works.
>
> --
> </chris>
>
> "The only thing more frightening than a programmer with a screwdriver
> or a hardware enginner with a program is a user with wire cutters and
> the root password." - Elizabeth Zwicky