Re: gitweb: Version independent mod_perl woes
Show 8 quoted lines
> -- >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),
};Show 22 quoted lines
> # 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 ----
Jakub Narebski
Poland