You can set the directories to be added to @INC by default when you compile Perl. Or more precisely: when you run Configure, before compiling.
So yes, the default is usually part of the binary distribution for a platform.
Makeshifts last the longest.
| [reply] |
Besides paths being compiled in, on win32 at least,
the @INC values are determined dynamically,
and the directory name where perl is located can make a difference, observe:
C:\dev\perls>dir 5.6.2
Volume in drive C has no label.
Volume Serial Number is 44B0-3C2E
Directory of C:\dev\perls\5.6.2
07/27/2004 06:30 AM <DIR> .
07/27/2004 06:30 AM <DIR> ..
07/27/2004 07:31 AM <DIR> bin
07/27/2004 06:30 AM <DIR> html
07/27/2004 06:50 AM <DIR> lib
07/27/2004 06:29 AM <DIR> site
0 File(s) 0 bytes
6 Dir(s) 34,454,638,592 bytes free
C:\dev\perls>5.6.2\bin\perl -le"print for @INC"
C:/dev/perls/5.6.2/lib
.
C:\dev\perls>rename 5.6.2 v5.6.2
C:\dev\perls>v5.6.2\bin\perl -le"print for @INC"
C:/dev/perls/v5.6.2/lib
C:/dev/perls/v5.6.2/site/lib
.
C:\dev\perls>
C:\dev\perls>rename v5.6.2 5.6.2f
C:\dev\perls>5.6.2f\bin\perl -le"print for @INC"
C:/dev/perls/5.6.2f/lib
.
C:\dev\perls>rename 5.6.2f f
C:\dev\perls>f\bin\perl -le"print for @INC"
C:/dev/perls/f/lib
C:/dev/perls/f/site/lib
.
C:\dev\perls>f\bin\perl -V
Summary of my perl5 (revision 5 version 6 subversion 2) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultip
+licity=define
useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DN
+O_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
optimize='-O1 -MD -DNDEBUG',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
+ lseeksize=4
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"c:\
+dev\perls\f\lib\CORE" -machine:x86'
libpth=C:\PROGRA~1\MIAF9D~1\VC98\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
+ comdlg32.lib advapi32.lib shell32.lib ole32.lib ol
eaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib versi
+on.lib odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool
+.lib comdlg32.lib advapi32.lib shell32.lib ole32.li
b oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib v
+ersion.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -l
+ibpath:"c:\dev\perls\f\lib\CORE" -machine:x86'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEX
+T PERL_IMPLICIT_SYS
Built under MSWin32
Compiled at Jul 27 2004 07:58:39
@INC:
C:/dev/perls/f/lib
C:/dev/perls/f/site/lib
.
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [d/l] |
During the configuration process in preparation to build a new release of perl on your system, there are a number of questions and settings that refer to the location of libraries. Essentially, these paths are "Compiled In"; however, you can always change the default during the build.
A nifty build trick is to add library paths to be added to the front of the @INC path, thus overriding the built-ins with your own modules, should you choose to do so.
The relevant portion of code is
sh Configure -Accflags='-DAPPLLIB_EXP=\"/other/lib/dir\"'
as per the CPAN Install - Build and Installation guide for perl5 page.
-v
"Perl. There is no substitute."
| [reply] [d/l] |
Improving the perl build system to allow relocation without
requiring recompilation is certainly do-able and is on the
P5P wish list. One way to implement this is to build all executables with dummy and very long paths stuffed into the executable, then write a utility to binary edit them when you move them. Sounds hacky, but in practice it works well and is better than the alternatives.
ActiveState's
reloc_perl utility
is an example of one way to do it.
| [reply] |
I imagine it's built from a constant in Config.pm. Config.pm is created when perl is built based on compiler flags and whatnot. (And in turn, Config.pm is used to extract options needed to compile modules.)
| [reply] |
Not quite. How would it find Config.pm without knowing the @INC?
The answer, as others have said, is that @INC is built in to the Perl binary, so you can't change it without recompiling the binary.
| [reply] |
*sigh* Too true. I must have bonked myself on the head too many times.
Are some generated instead of being hardcoded? I orignally installed my ActiveState perl in R:\U, but recently moved it to R:\Utils (without reinstalling), and I get:
>perl -le "$,=', '; print @INC"
r:/Utils/perl/lib, r:/Utils/perl/site/lib, .
I did have to edit Config.pm for PPM to work in the new directory.
| [reply] [d/l] |