You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Vladimir S. Tikhonjuk" <vs...@vst.donetsk.ua> on 2006/08/02 11:13:42 UTC

PerlSetVar

Hi all!

I set in httpd.conf variable like: PerlSetVar   var   test;

How can I get it in the startup.pl script ?

Vladimir.

Re: PerlSetVar

Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Aug 2, 2006, at 7:18 AM, Vladimir S. Tikhonjuk wrote:
> Well, nice advise, but where can I get $r ( Apache2::RequestRec )
> variable in startup.pl script ?
> In handler script - everything is O.K. But startup.pl!

You can't.

Apache2::RequestRec is a per-request variable.

startup.pl/httpd.conf are server configurations.

There is no $r, hence no ApacheRequestRec at that time.

You might want to look into

Apache2::ServerRec
	http://perl.apache.org/docs/2.0/api/Apache2/ServerRec.html

Apache2::ServerUtil
	http://perl.apache.org/docs/2.0/api/Apache2/ServerUtil.html

Re: PerlSetVar

Posted by Jonathan Vanasco <jo...@2xlp.com>.
>     Well, now I'll try to explain why I have asked such question. I  
> have
> startup.pl with connect_on_init dunction.
> Also, I want to use Apache::AuthDBI. And I want options for
> Apache::DBI->connect(...) to be stored into httpd.conf
> or another but the only place.
>     I think that I could declare vars into httpd.conf and then use  
> it in
> startup.pl and Apache::AuthDBI.
>     Storing connection options such as login and password into
> environment vars - not very good idea, I thik :)

Personally, I use ENV to set 'production#', 'dev#' id for the machines

the SQL passwords are hardcoded into the app, along with other  
traditionally environment variables , in a perl config and are  
accessed via something like this:

	$server{ $EVN{server_id} }{ $varname }

while there are some disadvantages to this...

i have 1 line in my httpd.conf that includes a httpd.conf for my  
modperl app, which I keep in svn along with the app
i only set 1 var in httpd.conf, and  don't use that powerful (yet  
bastardized integration of 2 things) mod_perl interface to httpd.conf  
- its all in the app

and everything is in svn.  in a single directory.  clustering is as  
easy as 'svn co' ,  oooh!


Re: PerlSetVar

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2006-08-03 at 08:47 +0300, Vladimir S. Tikhonjuk wrote:
>     Well, now I'll try to explain why I have asked such question. I have
> startup.pl with connect_on_init dunction.
> Also, I want to use Apache::AuthDBI. And I want options for
> Apache::DBI->connect(...) to be stored into httpd.conf
> or another but the only place.

In httpd.conf:

<Perl>
%MyConfig::DBI_CONNECTION_OPTIONS = (password => 'blah', etc.);
</Perl>

Then just access that variable where you need it.

- Perrin


Re: PerlSetVar

Posted by "Vladimir S. Tikhonjuk" <vs...@vst.donetsk.ua>.
Philip M. Gollucci пишет:

>Vladimir S. Tikhonjuk wrote:
>  
>
>>Philip M. Gollucci пишет:
>>
>>    
>>
>>>Vladimir S. Tikhonjuk wrote:
>>> 
>>>
>>>      
>>>
>>>>I set in httpd.conf variable like: PerlSetVar   var   test;
>>>>
>>>>How can I get it in the startup.pl script ?
>>>>   
>>>>
>>>>        
>>>>
>>>http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlSetVar_
>>>
>>>You might want to read and re-read and re-read and re-read ....
>>>The 2.0 Users Guide here:
>>>http://perl.apache.org/docs/2.0/user/
>>>
>>>HTH
>>>
>>>      
>>>
>>Well, nice advise, but where can I get $r ( Apache2::RequestRec )
>>variable in startup.pl script ?
>>In handler script - everything is O.K. But startup.pl!
>>    
>>
>http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_request_
>
>But that doesn't help you either.
>httpd.conf:
>	PerlSetEnv      var test
>
>startup.pl:
>	print STDERR "test => $ENV{test}\n"
>
>
>or you might look at
>	bash: export var='test' / tcsh: setenv var test
>	httpd.conf:
>		PerlPassEnv var
>
    Well, now I'll try to explain why I have asked such question. I have
startup.pl with connect_on_init dunction.
Also, I want to use Apache::AuthDBI. And I want options for
Apache::DBI->connect(...) to be stored into httpd.conf
or another but the only place.
    I think that I could declare vars into httpd.conf and then use it in
startup.pl and Apache::AuthDBI.
    Storing connection options such as login and password into
environment vars - not very good idea, I thik :)

Re: PerlSetVar

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Vladimir S. Tikhonjuk wrote:
> Philip M. Gollucci пишет:
> 
>> Vladimir S. Tikhonjuk wrote:
>>  
>>
>>> I set in httpd.conf variable like: PerlSetVar   var   test;
>>>
>>> How can I get it in the startup.pl script ?
>>>    
>>>
>> http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlSetVar_
>>
>> You might want to read and re-read and re-read and re-read ....
>> The 2.0 Users Guide here:
>> http://perl.apache.org/docs/2.0/user/
>>
>> HTH
>>
> Well, nice advise, but where can I get $r ( Apache2::RequestRec )
> variable in startup.pl script ?
> In handler script - everything is O.K. But startup.pl!
http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_request_

But that doesn't help you either.
httpd.conf:
	PerlSetEnv      var test

startup.pl:
	print STDERR "test => $ENV{test}\n"


or you might look at
	bash: export var='test' / tcsh: setenv var test
	httpd.conf:
		PerlPassEnv var




-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."

Re: PerlSetVar

Posted by "Vladimir S. Tikhonjuk" <vs...@vst.donetsk.ua>.
Philip M. Gollucci пишет:

>Vladimir S. Tikhonjuk wrote:
>  
>
>>I set in httpd.conf variable like: PerlSetVar   var   test;
>>
>>How can I get it in the startup.pl script ?
>>    
>>
>http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlSetVar_
>
>You might want to read and re-read and re-read and re-read ....
>The 2.0 Users Guide here:
>http://perl.apache.org/docs/2.0/user/
>
>HTH
>
Well, nice advise, but where can I get $r ( Apache2::RequestRec )
variable in startup.pl script ?
In handler script - everything is O.K. But startup.pl!

Re: PerlSetVar

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Vladimir S. Tikhonjuk wrote:
> I set in httpd.conf variable like: PerlSetVar   var   test;
> 
> How can I get it in the startup.pl script ?
http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlSetVar_

You might want to read and re-read and re-read and re-read ....
The 2.0 Users Guide here:
http://perl.apache.org/docs/2.0/user/

HTH


-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."