in reply to Can't locate Modules/test.pm in @INC

Actually,
use lib $ENV{ SOURCE_ROOT };
ought to be sufficient. Then all modules in ANYWHERE in the $SOURCE_ROOT tree will be addressable as subdir::subdir:: etc ::

BUT, rather than have to make a header for ALL your .pl files, it might be worth putting the following in your group login scripts (although in that case for every environment using the software so will need to be put in the next deployment script):

export PERL5LIB=$SOURCE_ROOT:$PERL5LIB
which has the same effect, but without needing to modify your .pl files at all!!

-M

Free your mind

Replies are listed 'Best First'.
Re^2: Can't locate Modules/test.pm in @INC
by Anonymous Monk on Feb 22, 2007 at 11:15 UTC
    Hi I tried both the options.
    When I included the use lib $ENV{ SOURCE_ROOT }; in .pl fine nothig changed, i got the same error again.
    And on trying the second option I was not able to locate the PERL5LIB env variable so created one and when i appended the $SOURCE_ROOT following error i got:
    login-linux-hyd-001{67}> which perl
    /pkg/perl/5.8/bin/perl
    login-linux-hyd-001{68}> setenv
    PERL5LIB /pkg/perl/5.8/bin/perl
    login-linux-hyd-001{69}> setenv PERL5LIB
    $SOURCE_ROOT:$PERL5LIB
    Bad : modifier in $ ($).
    login-linux-hyd-001{70}> setenv PERL5LIB
    $SOURCE_ROOT:$PERL5LIB Bad : modifier in $ ($).
    login-linux-hyd-001{71}> setenv PERL5LIB
    SOURCE_ROOT:$PERL5LIB
    login-linux-hyd-001{72}> echo $PERL5LIB
    SOURCE_ROOT:/pkg/perl/5.8/bin/perl
    login-linux-hyd-001{73}> setenv PERL5LIB
    $SOURCE_ROOT:/pkg/perl/5.8/bin/perl
    Bad : modifier in $ (/).
      The problem indicated by Bad : modifier in $ ($) is a problem with csh variable syntax. The colon has special significance if it follows a variable name. To isolate it, use {} around the variable name, much like in Perl. So
      setenv PERL5LIB ${SOURCE_ROOT}:$PERL5LIB
      should do what you want.

      However, the effort you are making to put (parts of) the original include path into $PERL5LIB is unnecessary. What you specify in $PERL5LIB is searched in addition to the original path. So, just

      setenv PERL5LIB $SOURCE_ROOT
      should be enough.

      Anno

      Unfortunately, I only have access to a sunos system today and I can't reproduce the problem you are now having. However, the impression I get is that SOURCE_ROOT is not yet itself defined when you tried the above. Also, it is worth asking what shell you are using (try the ps command to find out).

      -M

      Free your mind