Re: Compiling Perl with correct values in @INC
by Zaxo (Archbishop) on Aug 15, 2002 at 18:49 UTC
|
By default, the perl build configuration does an extended question-and-answer session during the configuration. Default answers are provided and are sane for most questions. If you give an incorrect answer, it's best to start over. You get a chance to edit the configuration before it's written into the Makefile.
Since some default answers may be drawn from the current perl installation, pay close attention to the LIBDIR and 'additional @ISA' questions. The -d option to configure automatically picks most of the defaults, so don't try that with a broken current perl.
It would be advisable to set PERL5LIBS before building.
After Compline, Zaxo
| [reply] |
Re: Compiling Perl with correct values in @INC
by Necos (Friar) on Aug 15, 2002 at 18:42 UTC
|
Looking at my Config.pm file, there seems to be some options for path inclusion of libraries.
Here are some of the more interesting lines from my Win32 machine:
archlib='C:\Perl\lib'
privlibexp='C:\Perl\lib'
glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/
+386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/u
+cblib /usr/shlib '
installsitearch='C:\Perl\site\lib'
installsitelib='C:\Perl\site\lib'
locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt
+/gnu/include /usr/GNU/include /opt/GNU/include'
loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /us
+r/GNU/lib /opt/GNU/lib'
sitearch='C:\Perl\site\lib'
sitearchexp='C:\Perl\site\lib'
sitelib='C:\Perl\site\lib'
sitelibexp='C:\Perl\site\lib'
xlibpth='/usr/lib/386 /lib/386'
You might want to check your Config.pm and see if all the lib paths are correct. This might help you to correct the @INC array (it should, but I may be wrong). Hope this helps some.
Update: I should note that even though I looked at a Win32 Config.pm, some of the ideas should apply. I forget whether or not scripts/programs/etc. read from Config.pm unless explicitly stated (i.e., use Config;). If I am wrong, I'd like some correction on the issue.
Theodore Charles III
Network Administrator
Los Angeles Senior High
4650 W. Olympic Blvd.
Los Angeles, CA 90019
323-937-3210 ext. 224
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;" | [reply] [d/l] [select] |
|
Editing Config.pm won't help anything. It's written when Perl is compiled from the config.sh file built by Configure.sh. The basic @INC paths are compiled into the Perl binary itself. Think about it this way -- if Perl can be installed just about anywhere (and it can be), how would it know where to find Config to find out where the modules are installed?
| [reply] |
|
Of course, when your @INC is incorrect, perl
can't find Config.pm....
$ perl -wle 'BEGIN {@INC = ()} use Config'
Can't locate Config.pm in @INC (@INC contains:) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Abigail | [reply] [d/l] [select] |
Re: Compiling Perl with correct values in @INC
by higle (Chaplain) on Aug 15, 2002 at 19:29 UTC
|
Thanks guys! The help is very much appreciated!
I've never dug into this part of the Perl beast until now, and I've found it rather hard to locate documentation outlining the building of the Perl executable. Is there a handy source of documents on this subject (read: a URL that I can give to the Unix dudes), or is this coming purely from experience and the READMEs?
Thanks some more,
higle
Update: Whew, got it all sorted out. Thanks to Zaxo, I was able to confidently reassure the Unix guys (and their managers, so on and so forth) that the change would be a painless one. Perl was rebuilt and configured with the appropriate lib paths. Thanks again to everyone and their contributions! | [reply] |
Re: Compiling Perl with correct values in @INC
by Courage (Parson) on Aug 15, 2002 at 20:14 UTC
|
- perl built on different OSes has different logic for @INC population.
- Your script will work just fine if you'll place at the very start of it:
BEGIN {
@INC = ('/dir1','/your/special/dir/here');
}
# rest of your code goes here
I use that approach sometimes in my scripts.
- recompiling perl is much easier that it initially seemes to. And lot of platform-specific READMEs help a lot.
addition: BTW what is your OS?
Courage, the Cowardly Dog
things, I do for love to perl...
| [reply] [d/l] |
|
The machine in question is running HP-UX, and I found one (1) document specific to building perl on that OS :c\
The problem was, Courage, without rebuilding the executable with the correct @INC, I would have to unshift(@INC, qw{dir dir dir...}); all the scripts that I wrote on that machine, as well as look forward to explaining this whole thing to the other programmers who use that box. That would truly have been a bummer of cosmic proportions.
higle
| [reply] [d/l] [select] |
|
Things are entirely different if you're building perl for many users on that machine.
I just looked at perl-5.8.0 source distribution, and found README.HPUX file there - it should help you in build process...
Courage, the Cowardly Dog
| [reply] |
|
This also works great if your hosting company doesn't want to install a particular module.
| [reply] |
Re: Compiling Perl with correct values in @INC
by wrffr (Novice) on Aug 16, 2002 at 03:35 UTC
|
If you can't rebuild the perl executable or you want to keep certain perl modules in a different directory for other reasons, just stick--
use lib "/path/to/perl/modules";
...at the beginning of your script. | [reply] |
|
| [reply] [d/l] [select] |
|
this will work but only in cases when perl will find "lib.pm" which, in turn, requires "Config.pm" and "Exporter.pm".
That said, @INC must be sane in this case.
I agree that @INC should *always* be sane, but what you will do if it is not? :)
Warmest wishes, Courage, the Cowardly Dog
| [reply] |