[thelist] CGI pass var 2 XSSI / SSI syntax / embedded Perl - 3 simple questions
George Dillon <> Evolt!
evolt at georgedillon.com
Wed Nov 14 15:47:51 CST 2001
I want every page to call a simple SSI for the left-hand menu, with that
file being unique to that page and having the same name as the page, but a
different extension...
Using a Perl CGI it's simple to create (and maintain) the SSIs (based on
each page's position in the tree, determined by the DOCUMENT_URI).
What I can't crack is how to have the page call its specific include without
hard-coding the link or calling it by using a new CGI (which is how I'm now
doing it).
Having tried and failed with various things like:
<!--#include virtual="<!--#echo var='DOCUMENT_URI' -->menu" -->
And not knowing how I can get my universal.cgi (at the top of each page) to
save (or modify) a variable which SSI could simply call as:
<!--#echo var="my_CGI_generated_menu_string" -->
I'm now reading the SSI and writing it to the page via CGI, so:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$menufile = "/home/usr/public_html$ENV{'DOCUMENT_URI'}";
$menufile =~ s/shtml/menu/;
open (MENU, "< $menufile") or die;
my @leftmenu = <MENU>;
close (MENU) or die;
foreach $line (@leftmenu) { print $line; }
So my 3 questions are...
1. Can CGI create/modify variables which can be accessed by an SSI later on
the same page?
2. Is there any syntactical trick which would enable me to simply add a
character (or 4) to the DOCUMENT_URI and call that as an SSI?
3. I've read about modules which allow Perl to be embedded directly in a
page. What are the dis/advantages of 'embedded Perl' and how simple is it
to get into?
TIA
George Dillon
More information about the thelist
mailing list