muntfish has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a question about how perl builds the @INC array at startup. I've checked perlrun but this hasn't really answered my questions.

I have PERL5LIB set to a list of directories, but I've noticed that perl can "detect" certain "special" subdirectories if they exist. In my case (running 5.8.0 on HP-UX) it will add subdirectories "5.8.0" and "PA-RISC1.1" into @INC if it finds them.

Is there a full list of all these "special" directories? Is there an equivalent to the version-specific directory, for other (older) versions of perl? My problem is that I'm trying to construct an environment where perl 5.8.0 can co-exist with perl 5.004_04, but I can't get the older perl to recognise any version-specific subdirectory (I've tried 5.004_04, 5.00404, 5.4.4 etc).

Update: if at all possible I need to get perl to see the version-specific directories without changing the source by adding "use lib" or -I.

If these special directories are set at compile time, is there any way of looking up what they were set to? perl -V didn't show this (unless I missed something).

Thanks.

s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&;

Replies are listed 'Best First'.
Re: Construction of @INC by different versions of perl
by eserte (Deacon) on Jun 10, 2004 at 09:36 UTC
    "use lib", which adds those "special" subdirectories automatically.

      Thanks, but I should have mentioned that I want to make this work without changing source code. I'll update my original node.

      Update: further to the above, I've discovered that "use lib" doesn't work with my old perl installation (5.004_04). Looks like this may be because $Config{version} is not defined, which doesn't sound good to me. Is there a workaround?

      s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&;
        Nevertheless, look at the lib.pm source code and/or documentation, especially the _get_dirs function.
        I know you said you don't want to modify your source, but to gleen from your statement about 5.0. To be backwards compatible with it, and perfectly compatible with current versions:
        sub BEGIN { push @INC, "/path/to/your/modules"; }
Re: Construction of @INC by different versions of perl
by inman (Curate) on Jun 10, 2004 at 12:48 UTC
    Try looking for Config.pm in the @INC path. It contains a number of definitions including many file paths, some of which are added to @INC. These paths are specifed when Perl is compiled / installed.