2

I'm a perl noob and I have a very basic question regarding the @INC post: How is Perl's @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)

Does the "otherlibdirs" Configure option completely rewrite the directories that are part of @INC, or merely add another directory? It's not clear to me from that answer what it does, and I don't want to screw up the whole @INC path.

Thanks!

Community
  • 1
  • 1
matthewb
  • 1,323
  • 2
  • 12
  • 18

1 Answers1

4

Perusing source of the Perl Configure script, we find the following usage information:

case "$otherlibdirs" in
''|' ') dflt='none' ;;
*)  dflt="$otherlibdirs" ;;
esac
$cat <<EOM
Enter a colon-separated set of extra paths to include in perl's @INC
search path, or enter 'none' for no extra paths.

EOM

So if you compile Perl with something like

    Configure -Dotherlibdirs=/usr/foo/bar:/usr/foo/bar/baz

Then the directories /usr/foo/bar and /usr/foo/bar/baz will be appended to the normal @INC built-in to the perl binary.

friedo
  • 65,762
  • 16
  • 114
  • 184
  • And now my complete command-line incompetence comes back into play: When I try to run that command, it's telling me "Configure: command not found". – matthewb Dec 13 '11 at 01:50
  • @user1088336 Is your question how to change `@INC` inside a perl script? Because this is something quite more fundamental. – TLP Dec 13 '11 at 05:26
  • I'm pretty sure I want to change the default INC. Right now, the directory where CPAN is building new perl modules is not included in the default INC. If I'm understanding the situation correctly, I could either tell every script where to find the modules it needs, or I could update the default INC statement so that it knows where to look to find the modules built by CPAN. Am I thinking about this correctly? – matthewb Dec 13 '11 at 16:35