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". ;-)
|