Source filters don't work in mod_perl. Period.
Because source filters don't work in string evals, and that's what
mod_perl is basically doing everywhere.
Liz
==================================================
At 1:15 PM +0200 8/18/06, Hendrik Van Belleghem wrote:
Switch is a source filter, which basically means that the module will
read the script source file and change it before executing. Switch
will transform those 'case' statements into a bunch of elsif blocks. I
assume Switch will have a hard time interpreting the httpd.conf file.
I'm not sure how mod_perl handles the inline-perl-in-httpd.conf
feature but I guess it'll be tricky. My 0.02 eurocents.
HTH
Kind regards
Hendrik
On 8/18/06, Krist van Besien <[EMAIL PROTECTED]> wrote:
Hello,
this is my first post to the mod_perl mailing list. I have been using
mod_perl for about a week now. I do however have quite a few years
Perl scripting experience.
What I am trying to do is: Make one httpd.conf that will be suitable
for all of our servers. We have about 20 (and growing) apache servers.
Their role can be terermined from their hostname, so mod_perl's <Perl>
sections seem especially well suited to do this.
Currently I have the following section in my httpd.conf:
526 <Perl>
527
528 # We get the hostname, and use it to:
529 # generate a PID file name
530 # generate log file names
531 # include a hostname dependent include file
532
533 use Sys::Hostname;
534 use Apache2::ServerRec;
535 use Apache2::ServerUtil;
536 use Switch;
537 my $VFL_hostname = hostname();
538 my $VFL_servertype = "";
539 $ServerName = $VFL_hostname;
540
541 $PidFile = "logs/$ServerName.pid";
542 $ServerName .= ".swisptt.ch";
543 print STDERR "ServerName = $ServerName\n";
544
545 switch ($VFL_hostname) {
546 case "mstvflfewprp2v" {
547 $VFL_servertype = "sony" ;
548 }
549 case /ms.vflfe(.*).v/ {
550 $VFL_servertype = $1;
551 }
552 else {
553 $VFL_servertype = "default";
554 }
555 }
556
557 my $VFL_include = "conf/$VFL_servertype.inc" ;
558 print STDERR "Including $VFL_include\n" ;
559 $Include = $VFL_include ;
560
561 $CustomLog = "logs/$VFL_hostname/access_log vfl" ;
562 $ErrorLog = "logs/$VFL_hostname/error_log" ;
563
564 my $VFL_serverroot = Apache2::ServerUtil::server_root() ;
565
566 unless ( -d "$VFL_serverroot/logs/$VFL_hostname" ) {
567 mkdir "$VFL_serverroot/logs/$VFL_hostname", 0755;
568 }
569
570 </Perl>
My problem: When I run apachectl test I get the following error:
String found where operator expected at
/opt/portal/webserver/conf/httpd.conf line 546, near "case
"mstvflfewprp2v""
(Do you need to predeclare case?)
Syntax error on line 527 of /opt/portal/webserver/conf/httpd.conf:
syntax error at /opt/portal/webserver/conf/httpd.conf line 545, near ") {"\n
And after staring at my code for hours I still can't find out what
might be the syntas errors...
- Perl version used is 5.8.5. I checked the contents of the @INC
variable (by adding a print STDERR @INC" statement in a seperate perl
section, and found out that on of the directories searched does
contains the switch.pm module.
I alos tested this piece of code by puting it in a small perl script,
and there it compiles just fine. But as part of a Perl section it does
not work. Why?
--
[EMAIL PROTECTED]
Bremgarten b. Bern, Switzerland
--
Hendrik Van Belleghem
Spine - The backbone for your website - http://spine.sf.net