in reply to setting environment variable issue

Option 1:

Before any use of DBI/DBD,

BEGIN { $ENV{ORACLE_HOME} = "..."; $ENV{LD_LIBRARY_PATH} = "..."; }

I think I heard this doesn't work. Something about a clone of the environment getting creating by the C runtime library before this, and this is what Oracle uses?

Option 2:

Set the environment before calling Perl.

ORACLE_HOME=... LD_LIBRARY_PATH=... perl ...

You could use a loader script for this.

Option 3:

Make the Perl script itself the loader script.

BEGIN { my $oracle_home = "..."; my $ld_library_path = "..."; if ($ENV{ORACLE_HOME} ne $oracle_home || $ENV{LD_LIBRARY_PATH} ne $ld_library_path ) { $ENV{ORACLE_HOME} = "..."; $ENV{LD_LIBRARY_PATH} = "..."; exec { $^X } $^X, $0, @ARGV; } }

Replies are listed 'Best First'.
Re^2: setting environment variable issue
by jaimon (Sexton) on Aug 11, 2011 at 08:48 UTC

    Oh thank you thank you thank you!!! Option 3 worked great!
    - J