Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: ENV Object?

by kwoff (Friar)
on Oct 29, 2001 at 20:48 UTC ( [id://121934]=note: print w/replies, xml ) Need Help??


in reply to ENV Object?

For Apache, you can use the 'SetEnv' directive. For mod_perl, there is a 'PerlSetEnv' configuration directive.

Anyway, maybe you meant $ENV{SYBASE} = '/sybase' ? (%ENV instead of %NEW).

Replies are listed 'Best First'.
Re: Re: ENV Object?
by dmmiller2k (Chaplain) on Oct 30, 2001 at 02:25 UTC

    You may have to do this anyway.

    In my experience, setting the environment variable with $ENV{SYBASE}='whatever' within a BEGIN block sets it too late, at least when using DBI with DBD::Sybase.

    I've had some success with something like this (which, BTW, makes a program nearly impossible to debug)

    BEGIN { #need this so you don't recurse indefinitely: if ( not exists $ENV{SYBASE_SET} ) { $ENV{SYBASE_SET} = 1; $ENV{SYBASE} = 'whatever'; # set the variable exec $0; # exec self with new env ## NOT_REACHED } }

    This approach works in cases where the modules one is 'use'ing have their own initialization inside BEGIN blocks.

    Edit: You also should make certain that this BEGIN block preceeds any uses or requires which may bring in such modules.

    dmm

    
    You can give a man a fish and feed him for a day ...
    Or, you can teach him to fish and feed him for a lifetime
    
      Hmmm - that doesn't seem quite right. I suspect that you are confusing the SYBASE env. variable with LD_LIBRARY_PATH.

      When working with these environment variables it's always important to remember when theyaare needed.

      DBI does not load the DBD::Sybase code when you issue a "use DBI". So it follows that you only need to set the SYBASE env. variable before you call DBI->connect() - unless you have a "use DBD::Sybase" statement, in which case you do need to have $ENV{SYBASE} defined and set correctly (because DBD::Sybase runs some Client Library initialization code when it gets loaded and that code needs the SYBASE env. variable to be set correctly.)

      The LD_LIBRARY_PATH variable, on the other hand, does need to get set before the script starts. You can't affect the shared library search directories for the current process (at least not on the platforms that I am aware of!)

      Michael

        Yes, you are absolutely right about LD_LIBRARY_PATH!

        I neglected to distinguish between the two because in practice, changes to SYBASE have usually had to be accompanied by commensurate changes to LB_LIBRARY_PATH, among other environment-specific variables.

        Thanks for reminding me.

        dmm

        
        You can give a man a fish and feed him for a day ...
        Or, you can teach him to fish and feed him for a lifetime
        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-24 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found