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

For some reason, I keep getting errors when I run a script. It looks like @INC doesn't contain the default paths that it should, so it's not recognizing any installed modules.

Adding paths to INC in a BEGIN block doesn't really work, and it seems unnecessary since @INC should (and did, until yesterday) have these paths by default. Has this happened to anyone before, or is there any explanation? I haven't installed Perl again or anything, it's just the default setup that came with my OS along with a few modules.
  • Comment on @INC is suddenly changed? Not recognizing any of my modules

Replies are listed 'Best First'.
Re: @INC is suddenly changed? Not recognizing any of my modules
by ikegami (Patriarch) on Sep 06, 2009 at 17:13 UTC

    Most of the paths are hardcoded into the executable. The only reasons they'd disappear is if you're using a different executable of it something is mucking with @INC.

    Other paths include those added by env var PERL5LIB, env var PERLLIB, Perl's -I cmd line opt, the lib module or manually.

    And then there's the case of paths being present, but not accessible. They could be relative paths and your current directory isn't what you think it is, or it could be a permissions problem.

      Setting the ENV variables makes no difference at all. Even if I put the absolute path in a BEGIN block, it still doesn't recognize the module. What sort of permissions problem could there be?
        Ok, I figured it out. Turns out /opt/local/bin was no longer in my path for some reason. The clue was when other utilities stopped working too. It's all back to normal now.
Re: @INC is suddenly changed? Not recognizing any of my modules
by Anonymous Monk on Sep 06, 2009 at 17:11 UTC
    Maybe you had these env vars defined
    export PERLLIB=foo;bar export PERL5LIB=foo;bar