Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add to @INC in Windows

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
US
I don't know why I'm having such a hard time figuring this out!?!?!? How can I permanently add a path/paths to @INC on Windows (ActivePerl 5.8.8)? By permanently, I mean that I don't want to have to add the path to @INC in every script, I just want it to be there.

As usual, thanks in advance!!!
 
You probably need to edit the registry. But I have no idea where in the registry you would look.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
What are you having to add every time? I have never had to add anything to @INC.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I have my own modules that I've created, that I want to maintain in a different directory than where all the "system" modules are located. I guess I could just make a sub-directory in the "normal @INC" directory.

FYI: This is what I've found on the web so far...

Appending to Perl's @INC array

The @INC array is a list of directories Perl searches when attempting to load modules. To display the current contents of the @INC array:

perl -e "print join(\"\n\", @INC);"

The following two methods may be used to append to Perl's @INC array:

1. Add the directory to the PERL5LIB environment variable.
2. Add use lib 'directory'; in your Perl script.

My problem is that I'm on Windows and I don't see a PERL5LIB env variable anywhere...and I don't want to have to add #2 to every script!?!?!?
 
I use the following at the top of every script I write..
Code:
#!/usr/bin/perl

# Set Error Trapping
use CGI::Carp qw(fatalsToBrowser warningsToBrowser); 
use warnings;
use strict;

[b]# Set Module location
use FindBin qw($Bin);
use lib "$Bin";[/b]

Then every module I hand roll is put in the default CGI-BIN location.

You know that they are modules as the extention is .pm so it's easy to sort the wheat from the chaff at a glance.

well that's how I do it anyhow :)



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I'm using ActivePerl - tried
Code:
print "$_\n" foreach (@INC) ;
and searched the registry for it's output. No success. I did however find the following entry in .../Perl/html/changes-58.html (this file was built/extracted when perl was installed)
ActivePerl will now evaluate 'sitecustomize.pl' at startup if present. The ActivePerl distribution does not ship with this file, but it is a hook that the system administrator can use to set up set up additional site specific @INC entries.
I would have guessed that sitecustomize.pl would need to be identifiable through one of the original @INC values. Tried with no success. Also placed the file under .../perl/bin/. again with no success.

Later found the following in .../perl/htm/lib/Pod/perlrun.html
Perl can be built so that it by default will try to execute $Config{siteperl}/sitecustomize.pl at startup. This is a hook that allows the sysadmin to customize how perl behaves. It can for instance be used to add entries to the @INC array to make perl find modules in non-standard locations.
Tried to {print "$Config{'siteperl'}"} but it turns out to be undef for me. When I installed perl, I can't say one way or the other if I requested it to recognize and/or look for the sitecustomize.pl file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top