Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

modifying @INC other than use lib?

by Bukowski (Deacon)
on Apr 18, 2005 at 11:51 UTC ( #448794=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I'm on MacOS X and I have a couple of machines here, one Powerbook and one G5 desktop. Perl (apparently reporting the same version for both) has different @INC for each, and this is causing issues for gd-pm581 ( that I have installed via fink (as I can never get it to compile cleanly out of CPAN)
ashtaroth:~ dswan$ perl -e "print (@INC)" /sw/lib/perl5/5.8.1/darwin-thread-multi-2level/sw/lib/perl5/5.8.1/sw/l +ib/perl5/sw/lib/perl5/darwin/System/Library/Perl/5.8.1/darwin-thread- +multi-2level/System/Library/Perl/5.8.1/Library/Perl/5.8.1/darwin-thre +ad-multi-2level/Library/Perl/5.8.1/Library/Perl/Network/Library/Perl/ +5.8.1/darwin-thread-multi-2level/Network/Library/Perl/5.8.1/Network/L +ibrary/Perl. ashtaroth:~ dswan$
Embley-m6:/System/Library/Perl/5.8.1/darwin-thread-multi-2level dswan$ + perl -e "print (@INC)" /System/Library/Perl/5.8.1/darwin-thread-multi-2level/System/Library/P +erl/5.8.1/Library/Perl/5.8.1/darwin-thread-multi-2level/Library/Perl/ +5.8.1/Library/Perl/Network/Library/Perl/5.8.1/darwin-thread-multi-2le +vel/Network/Library/Perl/5.8.1/Network/Library/Perl.Embley-m6:/System +/Library/Perl/5.8.1/darwin-thread-multi-2level dswan$
The GD install has gone into /sw/lib/perl5/5.8.1/darwin-thread-multi-2level on both machines.

I know I can push paths into @INC with "use lib" but is there a way I can just get Perl to accept a new @INC permanently without major fiddling?



Bukowski - aka Dan (
"Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly

Replies are listed 'Best First'.
Re: modifying @INC other than use lib?
by bsdz (Friar) on Apr 18, 2005 at 11:57 UTC
    you can either set the environment variable PERL5LIB or edit your
      Never edit your that's meant to be a runtime reference to a number of settings that your Perl was compiled with.

      In particular, the initial value for @INC doesn't even come from there: it comes from a hardwired path compiled into the binary. Otherwise, how could Perl find the file? Psychic powers?

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Thanks Randal,

        I didn't get around to modifying it anyway before I hit on a lower tech solution:

        cd /sw/lib/perl5/5.8.1/darwin-thread-multi-2level/ sudo cp -R GD /System/Library/Perl/5.8.1/darwin-thread-multi-2le +vel/ sudo cp -R auto/GD/ /System/Library/Perl/5.8.1/darwin-thread-multi-2l +evel/auto/
        I did try this before but failed to copy across the auto/ and it was complaining about not being able to find the loadable object.

        Also for the record I did also try this with symlinks and it didn't appear to work :/


        Bukowski - aka Dan (
        "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly
        Otherwise, how could Perl find the file? Psychic powers?

        I think there's a Perl6 RFC on that one. ;)

        Editing your can be your only option sometimes; especially when relocating your Perl binary/library tree, and switching between using nmake or dmake in a Windows environment.
      This is why I was wondering if there was something more MacOS X specific as the only "" I can find on the system is the config for Fink.. not Perl...


      Scratch that - "find" finds what "finder" cannot on MacOS X - I am a Linux user at heart, this OS X stuff is still a bit alien to me :)

      Bukowski - aka Dan (
      "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly
Re: modifying @INC other than use lib?
by Fletch (Bishop) on Apr 18, 2005 at 12:19 UTC

    Looks like you've sourced Fink's /sw/bin/ script in the first case, as that would alter PERL5LIB just that way.

Re: modifying @INC other than use lib?
by Taulmarill (Deacon) on Apr 18, 2005 at 12:08 UTC
    i would also highly recomend to build your own perl, it's realy easy and works very well for me. just download, untar,, make, make test, make install (the usual).
    i build modules via cpan-shell.
Re: modifying @INC other than use lib?
by polettix (Vicar) on Apr 18, 2005 at 17:51 UTC
    The advantage of using use lib is that it also adds the directory specific to the architecture.

    Quick-and-very-dirty workarounds:

    • Make a dummy "pragma" module which simply lists the include directories you want:
      # In, located in standard perl lib directory package myInc; use lib /path/to/my/special/lib; 1;
      This only shifts the problem, but you have the advantage of a simpler inclusion and, what's better, the fact that you don't have to change anything in your scripts, only in the local myInc package:
      # ... in your script use myInc; use GD; # or whatever in your local lib # ...
    • given the fact that you're always using strict (aren't you?!?), you could put the use lib directly in, but I've never suggested you to do that :)
    The first solution seems the one to go if you want to give these headless advices a try. I only hope merlyn's hammer won't be too heavy on me!

    Update: fixed 8-PM typo, thanks to eric256 for signaling!

    Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

    Don't fool yourself.

      You wrote use base in your examples when I'm sure you meant use lib

      Eric Hodges

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://448794]
Approved by jbrugger
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2023-09-23 22:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found