...
$ENV{LD_LIBRARY_PATH} = "$ENV{ORACLE_HOME}/lib";
...
exec 'env',$0,@ARGV; # <<<< brrrrr!
Notice that all this solution does is a) on startup, set the environment variable LD_LIBRARY_PATH to what you want (that's a mistake: it should have appended to it, not set=replace!) and b) re-spawn (=replace current process with new, which keeps same PID) perl script via exec which will take into consideration the new value of the environment variable (ideally) while c) guarding against re-spawning ad-infinitum by setting yet another environment variable/flag. Yikes!
Using a shell script wrapper (contained in the question) does the same and in my opinion more cleanly.
Here is my suggestion: tell DynaLoader where to additionally look for libraries after executing your perl script but before loading troublesome module. This is what the manual says on how this works:
@dl_library_path should also be initialised with any other directories that can be determined from the environment at runtime (such as LD_LIBRARY_PATH for SunOS <<the OS Pericles used during the Pelloponisian War ;)>>).
After initialisation @dl_library_path can be manipulated by an application using push and unshift before calling dl_findfile(). Unshift can be used to add directories to the front of the search order either to save search time or to override libraries with the same name in the 'normal' directories.
The load function that dl_load_file() calls may require an absolute pathname. The dl_findfile() function and @dl_library_path can be used to search for and return the absolute pathname for the library/object that you wish to load.
Notice the "that can be determined from the environment at runtime". That's why you need to re-spawn after modifying said enviroment variable. Anyway, I can't test it but pushing to @dl_library_path should do the trick. See Cleanly adding a directory to DynaLoader's search path? how to do that. For me, this is the cleanest solution.
bw, bliako |