in reply to Re: SSI in CGI scripts?
in thread SSI in CGI scripts?

I sort of modified that code:
if( $ThePost =~ /(\[include\])(\S+?)(\[\/include\])/ ) { my $inpath = $1; my $include = '<!--#include virtual="/directory/'.$inpath.'" -->'; $ThePost =~ s/(\[include\])(\S+?)(\[\/include\])/$include/ig; }
This didn't work, however. I really can't do it through print. I have to add it to the variable $ThePost.

-NM

Replies are listed 'Best First'.
RE: RE: Re: SSI in CGI scripts?
by a (Friar) on Nov 14, 2000 at 02:29 UTC
    Probably because you've got 3 set of parens, so:
    $1 eq "[include]"; $2 eq <whatever path you wanted> $3 eq "[/include]";
    and your s/ would replace all of it by $include. Did you want:
    $ThePost =~ s/(\[include\])(\S+?)(\[\/include\])/${1}$include${2}/ig; or: $ThePost = "[include]$include[/include]";
    This won't work for multiple [include][/include]'s in the same ThePost, though the first might. Guess I'm still not clear, I thought you wanted to replace the include tags w/ the ssi #include instruction for the filename found between the tags. Don't see why you want to put your [include] tags back in to the output stream.

    a