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

G. Wade Johnson gwadej at anomaly.org
Tue Dec 6 05:10:04 PST 2005


As suggested by several people the "use lib" and begin block techniques should
both solve yuor problem.

I would be concerned about 'the @INC array points to non-existent
directories'. This normally means one of two things:

1. Someone built the Perl distribution for one location, and then moved
   the directory structure to a different location.
2. Someone downloaded a binary Perl distribution and installed it in a
   different location than it was built for.

You need to check with whoever installed your Perl and get them to correct
this. Depending on what all is missing you may not be able to 'use lib' or
even 'use strict'.

Recompiling Perl for a particular location is pretty straight-forward (at
least under Unix). Under Windows, the ActiveState installer sets everything up
correctly, so there should be no need to move the directories.

G. Wade

On Mon, 05 Dec 2005 20:46:54 -0600
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


-- 
I've been living on the edge too long, where the winds of limbo roar.
                      -- "Veteran of Psychic Wars", Blue Oyster Cult


More information about the Houston mailing list