You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Patrick Galbraith <pa...@mysql.com> on 2006/11/12 22:21:14 UTC
Rusty perl question
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
Re: Rusty perl question
Posted by Steve Hay <st...@uk.radan.com>.
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...
Can't you just "eval { use Apache2::Request }" and use that if it
loaded, else fall back on CGI?
--
------------------------------------------------
Radan Computational Ltd.
The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.
Re: Rusty perl question
Posted by Issac Goldstand <ma...@beamartyr.net>.
Steve Hay wrote:
> Issac Goldstand wrote:
>> 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.
>
> This doesn't tell you whether libapreq is available or not, though.
>
>
That's true - if that's questionable, he'd still need to eval it, as you
rightly pointed out.
Issac
Re: Rusty perl question
Posted by Steve Hay <st...@uk.radan.com>.
Issac Goldstand wrote:
> 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.
This doesn't tell you whether libapreq is available or not, though.
>
> 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
--
------------------------------------------------
Radan Computational Ltd.
The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.
Re: Rusty perl question
Posted by Issac Goldstand <ma...@beamartyr.net>.
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