Re: Rusty perl question

Issac Goldstand <[email protected]>
Newsgroups gmane.comp.apache.apreq
Message-ID <[email protected]>
Is this what you mean?

  use constant MP_GEN => $ENV{MOD_PERL}
      ? { ( exists $ENV{MOD_PERL_API_VERSION} and 
            $ENV{MOD_PERL_API_VERSION} >= 2 ) ? 2 : 1 }
      : 0;

It sets 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.

Then you can

    require foo if (MP_GEN == 2);

or whatever.

(See 
http://perl.apache.org/docs/2.0/user/porting/porting.html#Porting_a_Module_to_Run_under_both_mod_perl_2_0_and_mod_perl_1_0)

  Issac

Patrick Galbraith wrote:
> Hi all,
>
> I used to know the trick, I think, but can't remember. I want to code 
> my application to be smart about whether it's on a system that can use 
> mod_perl2/apreq, or if I have to use CGI. I 've code my app to use CGI 
> successfully, but would like to keep the code that I worked to get 
> apreq working as well. I would like for my application to be smart 
> enough to say use apreq if it's there, or use CGI if it isn't. What's 
> the magical trick to toggle the 'use libfoo' or 'use libfee'? Kindof 
> like #ifdefs in C...
>
> Thanks!
>
> Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.