[pm-h] How to update @INC from within a script?

Jay Vogt jvogt at houston.oilfield.slb.com
Mon Dec 5 18:46:54 PST 2005


When I point to a particular Perl executable the @INC array
points to non-existent directories. I've tried to update @INC
within my script to point to the directories which do contain DBI
using the unshift technique found in the O'Reilly books (whether
in a BEGIN statement or elsewhere in the script before
I execute "use DBI"). Printing the contents of @INC (by commenting
out "use DBI") shows that the array is modified, but when including
"use DBI" I get an error that DBI.pm is not in @INC and it lists
only those non-existent directories.

The "use DBI" statement seems to be processed at script compilation
time and not following the BEGIN block. The only way my script
sees the DBI module is if I set the environment variable PERL5LIB
in an xterm before running the script. Setting $ENV{PERL5LIB}
within my script does not work.

Any suggestions on how to modify @INC from within a script
so that it is actually read?


Jay Vogt

More information about the Houston mailing list