... $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


In reply to Re^5: Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle? DynaLoader solution by bliako
in thread Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle? by jrw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.