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

i'm trying to use the same ssi files for a menu system. the files work fine with the normal include virtual call from the html pages, yet do not work within perl, i tried to use a ../file name, and a url/file name, yet these do not work, i was wondering if perhaps i need to add soemthing like a .htaccess file to the cgi-bin? or if there is special code i need to use. this is going within a header file in my perl coding..

lief

Replies are listed 'Best First'.
Re: ssi within perl
by mandog (Curate) on Sep 26, 2001 at 05:55 UTC
Re: ssi within perl
by perrin (Chancellor) on Sep 26, 2001 at 05:39 UTC
    Apache's SSI processor does not work on the output of CGI scripts. You need to use one of emulation modules from CPAN, like CGI::SSI.
Re: ssi within perl
by Tetramin (Sexton) on Sep 27, 2001 at 02:52 UTC
    Often it is only the include and the exec command that people want. For one of my scripts I took only some lines out of CGI::SSI and send my templates through it.
    $template =~ s/<!--#(include|exec) (\w+)="(.*)"\s*-->/ssi($1,$2,$3)/eg +; sub ssi{ my($t,$n,$v) = @_; if($t eq 'exec'){ if($n eq 'cgi'){ $t = 'include'; $n = 'virtual'; }elsif($n eq 'cmd'){ return `$v` } } if($t eq 'include'){ if($n eq 'file' || ($n eq 'virtual' && $v=~/^\//)){ my $file = $v=~/^\// ? $ENV{DOCUMENT_ROOT}.$v : $v; open(SSI, $file) or return "[SSI: $!]"; my $re = join '', <SSI>; close(SSI); return $re; }elsif($n eq 'virtual'){ eval "use LWP::Simple;1;"; return "[SSI: $@]" if $@; return get($v); } } }