in reply to Howto Call Package from a Subdirectory

The other suggestions are correct, you want to:

use lib '/path/to/modules_src';

But this isn't much fun maintanence wise, because when you move around your application directory you have to update this line of code. The FindBin module, which has come with perl for a while now, takes care of this problem:

use FindBin; use lib "$FindBin::Bin/../modules_src";

This way you can move around the application directory at will and @INC will get set properly without modifying the code.

EDIT:

Based on your application directory's structure, you would want to use:

use FindBin; use lib "$FindBin::Bin/modules_src";

Because the program you are ruuning is in the root of your application directory

Replies are listed 'Best First'.
Re^2: Howto Call Package from a Subdirectory
by arpad.szasz (Pilgrim) on May 06, 2007 at 21:28 UTC
      That works, more or less, but gives me a warning, on Windows/perl5.6.1: Use of uninitialized value in concatenation (.) or string at [...]/lib/File/Spec/Win32.pm line 240.

      The reason is the lack of the third parameter to catpath.

      What's more, it still has a trailing backslash (probably a slash on Unix), which is not my idea of ideal. It might work, or it might fail on some platforms.

      The following code no longer produces the warning, but I still get the trailing backslash:

      $RealBin = catpath ((splitpath (rel2abs ($0)))[0,1], '');

      File::Spec is dumb.

        I now use this (only tested on Linux):

        our $RealBin; BEGIN { use File::Basename 'dirname'; use File::Spec::Functions 'rel2abs'; $RealBin = rel2abs( dirname( __FILE__ ) ); } use lib "$RealBin/lib";