Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

PerlSetEnv and PerlRequire

by Likeless (Acolyte)
on Aug 17, 2006 at 16:29 UTC ( [id://567960]=perlquestion: print w/replies, xml ) Need Help??

Likeless has asked for the wisdom of the Perl Monks concerning the following question:

Good day,

I am trying to write a startup script (ie. PerlRequire) that uses a value set in httpd.conf by PerlSetEnv.

The value does not seem to be passed to the startup script.

I have checked $ENV{'mod_perl'} and startup.pl is indeed running under mod_perl.

Does anybody know if this is standard behaviour, and if there is any way to pass the value in from httpd.conf?

Replies are listed 'Best First'.
Re: PerlSetEnv and PerlRequire
by friedo (Prior) on Aug 17, 2006 at 16:47 UTC
    As far as I know, PerlSetEnv variables are only set in the CGI environment during a request cycle, not when Apache is starting up. You will need to set the variable when you start Apache for your startup script to see it.

      According to the mod_perl docs,

      PerlSetEnv allows you to specify system environment variables and pass them into your mod_perl handlers. These values are then available through the normal perl %ENV mechanisms.

      Apparently, it's set for all mod_perl handlers, not just for the "CGI environment during a request cycle". (Is that a weird way of saying Apache::Registry?)

      Likeless: technically, the startup script is not a handler. The var might not be set for it. You are checking for the var in %ENV, right? You might want to ask your question on the mod_perl mailing list. That might even be something they'd want to fix.

        (Is that a weird way of saying Apache::Registry?)

        No, it's a stupid way of saying it. :)

Re: PerlSetEnv and PerlRequire
by Anonymous Monk on Aug 17, 2006 at 22:54 UTC
    In httpd.conf:
    <Perl> $My::ENV->{one} = 1; $My::ENV->{two} = 2; </Perl>
    In startup.pl:
    print "$My::ENV->{one}\n"; print "$My::ENV->{two}\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://567960]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-10-06 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (43 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.