PERL5LIB does *not* clobber existing @INC. It merely adds (prepends) the specified path(s) to @INC
Seems to me that @INC should still be locating your modules, even though some additional paths have bee prepended to it by PERL5LIB.

This is exactly the problem. The Oracle perl library path is prepended to the non-Oracle perl library path. That means that all modules will be loaded from Oracle's perl, and only if they do not exist there, they will be loaded from the non-Oracle perl. No problem for custom modules installed somewhere in in the non-Oracle library path. For pure-perl modules, this should be no big thing, too. But XS modules will likely cause trouble due to mixing perl versions. Also note that pragmatic modules will be loaded from the wrong perl version. That may also cause trouble due to different internals.

The only in-perl solution is to clean up @INC before loading any module, including pragma modules. This could happen in a BEGIN block at the top of the perl script. Of course, that BEGIN block could also be implicit, as in use. With a module name that does not exist anywhere in the Oracle perl library path, that module would be loaded from the non-Oracle librariy path. Example:

File GetRidOfOracle.pm somewhere in the non-Oracle perl library path:

package GetRidOfOracle; # @INC is messed up, so we must not load any other module here. # This includes "strict" and "warnings". sub isOracleDirectory { my $dirname=shift; # We are on Windows. / and \ are equal. Case does not matter. # Change to local conditions as needed. $dirname=~tr|\\|/|; return lc($dirname)=~m|/oracle/|; } # remove Oracle Directories from @INC: @INC=grep { !isOracleDirectory($_) } @INC; 1;

Any perl script that may suffer from Oracle's PERL5LIB:

#!/usr/bin/perl # ^- Change perl path and parameters as needed use GetRidOfOracle; # <-- must be the very first command in the script +! use v5.12; use strict; use warnings; # your code here ... # For a demo, set PERL5LIB as Oracle would do, then run this script. # No Oracle directory should be printed as long as GetRidOfOracle is l +oaded. say for @INC;

Update:

I just remembered that the OP uses perl 5.8.0, so the demo won't work. Use this for 5.8.0:

#!/usr/bin/perl # ^- Change perl path and parameters as needed use GetRidOfOracle; # <-- must be the very first command in the script +! use strict; use warnings; # your code here ... # For a demo, set PERL5LIB as Oracle would do, then run this script. # No Oracle directory should be printed as long as GetRidOfOracle is l +oaded. print "$_\n" for @INC;

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: Need way to override PERL5LIB from inside pl script file by afoken
in thread Need way to override PERL5LIB from inside pl script file by nmork

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.