On Mon, Sep 20, 2004 at 10:53:09PM +0200, Tom Schindl wrote: > Hi, > > !please always reply to the mailing list so the thread doesn't get broken! > > well mp uses this value internally and many CPAN-Modules do so either. > Versions > > mp1 = VERSION < 1.99 > mp2 = VERSION >= 1.99 > > The real syntax would be: > > ----------------->8----------------- > use mod_perl; ## exists in mp1 and mp2 > > ## set the constant to 0 if mp1 and to 1 if mp2 > ## but also subversions are working like this e.g. >= 1.99_12 which > ## means the version the version must be at least 1.99_13 > use constant MP2 => ($mod_perl::VERSION >= 1.99); > > BEGIN { > if( MP2 ) { > require Apache::Const; > Apache::Const->import(-compile => > 'HTTP_UNAUTHORIZED','HTTP_INTERNAL_SERVER_ERROR','DECLINED','HTTP_FORBIDDEN','OK'); > } else { > require Apache::Constants; > > Apache::Constants->import('HTTP_UNAUTHORIZED','HTTP_INTERNAL_SERVER_ERROR','DECLINED','HTTP_FORBIDDEN','OK'); > } > } > > ## proceed with your code > ----------------->8----------------- > > Tom > > > John Siracusa wrote: > >On Mon, 20 Sep 2004 21:19:58 +0200, Tom Schindl <[EMAIL PROTECTED]> wrote: > > > >>Are you looking for this: > >>-------------->8-------------- > >>use constant MP2 => ($mod_perl::VERSION >= 1.99_12); > >>-------------->8-------------- > > > > > >I don't know. What is that? :) Is that the "officially blessed" way > >to do this, or just another alternative that happens to work? Also, > >what's the equivalent for MP1? "$mod_perl::VERSION < 1.99_12"? > > > >-John
I use the following, avoiding the need to pull in mod_perl.pm unless the MOD_PERL environment variable exists. use constant MOD_PERL => exists($::ENV{'MOD_PERL'}) ? (require('mod_perl.pm'), $mod_perl::VERSION >= 1.99) ? $mod_perl::VERSION : 1 : 0; and then the Perl optimizer will take care of optimizing away my simple tests for (MOD_PERL) == 0 (not mod_perl) (MOD_PERL) == 1 (mod_perl 1) (MOD_PERL) > 1 (value 1.99 and above for mod_perl 2 and above) Cheers, Glenn -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html