From: Jakub Narebski Date: Thu, 21 Dec 2006 18:09:35 GMT Subject: Re: gitweb: Version independent mod_perl woes Message-ID: <200612211909.35615.jnareb@gmail.com> In-Reply-To: <200612211807.54668.jnareb@gmail.com> Jakub Narebski wrote: > -- >8 -- > # Set the constant MP_GEN to 0 if mod_perl is not available, > # to 1 if running under mod_perl 1.0 > # and 2 for mod_perl 2.0 > use constant MP_GEN => $ENV{'MOD_PERL'} >         ? { ( exists $ENV{'MOD_PERL_API_VERSION'} and >               $ENV{'MOD_PERL_API_VERSION'} >= 2 ) ? 2 : 1 } >         : 0; Actually, the error was here. It works like expected for use constant { MP_GEN => ($ENV{'MOD_PERL'} ? ( exists $ENV{'MOD_PERL_API_VERSION'} and $ENV{'MOD_PERL_API_VERSION'} >= 2 ) ? 2 : 1 : 0), }; > # use appropriate mod_perl modules (conditional use) > BEGIN { >         if (MP_GEN == 2) { >                 require Apache2::RequestRec; >                 require Apache2::ServerRec; >                 require Apache2::Response; >                 require Apache2::Const; >                 import Apache2::RequestRec; >                 import Apache2::ServerRec; >                 Apache2::Const->import(-compile => qw(:common :http)); >         } elsif (MP_GEN == 1) { >                 require Apache; >                 require Apache::Constants; >                 import Apache; >                 Apache::Constants->import(qw(:common :http)); >         } > } > > # mod_perl request > my $r; > $r = shift @_ if MP_GEN; > -- >8 -- Sorry for the noise. -- Jakub Narebski Poland