Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Win32 @INC behavior

by richz (Beadle)
on Nov 16, 2005 at 04:08 UTC ( #508895=note: print w/replies, xml ) Need Help??


in reply to Re: Win32 @INC behavior
in thread Win32 @INC behavior

This is all on the same computer. I am not relying on my PATH to run perl and I am just copying perl.exe and the perl56.dll. I ran dependency walker and that is the only dynamically linked non-OS library linked in perl.exe.

I was always under the impression that the @INC variable is fixed once you compile perl.exe but there was on thread here that mentioned it seems to be somewhat dynamic but not in the way I'm finding out. That thread seemed to indicate that moving perl.exe around would result in @INC being adjusted so the directories it contains have their path adjusted accordingly.

Replies are listed 'Best First'.
Re^3: Win32 @INC behavior
by blm (Hermit) on Nov 16, 2005 at 06:09 UTC
    In my attempts to mimick this problem I got an error about missing Config.pm when running perl -V when I removed all the perl except perl.exe and perl58.dll and perl5.8.0.exe (Yes I am doing this under perl 5.8 because that is all I have on Win32). The config.pm that it is refering to (I think) is c:\perl\lib\Config.pm and it contains alot of the info needed for the -V screen. I don't know if this helps you.
Re^3: Win32 @INC behavior
by osunderdog (Deacon) on Nov 16, 2005 at 14:46 UTC

    @INC is the result of all perllib additions that have been made by perl upon startup. It is not fixed at all. Although there is a portion of it that is fixed at compile time. The @INC is a combination of compile time settings, PERLLIB environment variable, perl command line -I parameters and use lib statements.

    For example on linux, if you do:

    PERLLIB=envbar perl -I cmdfoo -V -e "use lib ('usebaz');"

    You will see the resulting @INC :

    @INC: usebaz cmdfoo envbar /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl .

    There appears to be an order of precidence here too. use lib is first, -I option is second, PERLLIB is third and compiled settings is fourth.

    Update: added use lib to the example.

    Hazah! I'm Employed! But this place sucks

      Yeah I guess I meant fixed if not modified using environment variable, command line option, etc. The location of the perl executable seems to affect the @INC variable and I think a reply further down in this thread is a convincing reason. Thanks.
Re^3: Win32 @INC behavior
by bart (Canon) on Nov 16, 2005 at 20:49 UTC
    Note: I'm doing a lot of handwaving here... I seem to recall having read about this, but I've not looked it up to confirm my beliefs. I'll look it up later, I promise.
    I was always under the impression that the @INC variable is fixed once you compile perl.exe
    That's right. That's even the case for Perl on Windows... Except: perl itself changes the directories found in the hardwired @INC inside the perl exectutable, into directories relative to where it currently resides. That happens to lib (relative position to perl: ../lib) and site/lib (relative position: ../site/lib), where the perl executable resides in bin, relative to the perl installation root.

    You could say it's a simple s/^$HARDWIRED_ROOT/$CURRENT_ROOT/, done inside perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://508895]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2020-05-29 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (166 votes). Check out past polls.

    Notices?