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

Kristofer Hoch kristoferhoch at yahoo.com
Tue Dec 6 02:45:41 PST 2005


Jay,
    Try this at the very top of your script
  
  #!/path/to/perl 
  BEGIN { push(@INC, '/path/to/DBI/directory'); }

  
Jay Vogt <jvogt at houston.oilfield.slb.com> wrote:  All,

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?

Thanks,

Jay Vogt

_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston




-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++ 
W+++ w PS PE t++ b+ G e r+++ z++++
------END GEEK CODE BLOCK------
		
---------------------------------
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/mailman/private/houston/attachments/20051206/533493b5/attachment.html


More information about the Houston mailing list