stas 2003/12/03 20:51:35 Modified: src/docs/2.0/user/porting porting.pod Log: an example of a tri-state MP_GEN constant idiom Revision Changes Path 1.15 +11 -0 modperl-docs/src/docs/2.0/user/porting/porting.pod Index: porting.pod =================================================================== RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/porting/porting.pod,v retrieving revision 1.14 retrieving revision 1.15 diff -u -u -r1.14 -r1.15 --- porting.pod 28 Aug 2003 18:42:39 -0000 1.14 +++ porting.pod 4 Dec 2003 04:51:35 -0000 1.15 @@ -1271,6 +1271,17 @@ There is more information about this issue here: http://pause.perl.org/pause/query?ACTION=pause_04about#conventions +Some modules, like C<CGI.pm> may work under mod_perl and without it, +and will want to use the mod_perl 1.0 API if that's available, or +mod_perl 2.0 API otherwise. So the following idiom could be used for +this purpose. + + use constant MP_GEN => $ENV{MOD_PERL} + ? eval { require mod_perl; $mod_perl::VERSION >= 1.99 ? 2 : 1 } + : 0; + +It sets the constant C<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. Here's another way to find out the mod_perl version. In the server configuration file you can use a special configuration "define" symbol
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]