in reply to using a file in a different dir

The use statement searches a module in @INC. The lib pragma adds directories to @INC. So you will likely want to tell Perl (for this script) to also look elsewhere for your code:

use lib '../foo';

If you have a directory with modules that you always want to use, you can set $ENV{PERL5LIB} (or was it $ENV{PERL5INC} ?). If you only want to alter the module search path for one invocation of your program, you can invoke it as:

perl -I../foo my_script.pl

Replies are listed 'Best First'.
Re^2: using a file in a different dir
by dtr (Scribe) on Nov 01, 2005 at 10:12 UTC

    Saying use lib "../lib"; works fine if you're always going to run the script from the directory in which it's located. If you run it from somewhere else, however, this will break.

    It's better is to use the FindBin module in conjunction with use lib. For example, you could say:-

    use FindBin '$Bin'; use lib "$Bin/../lib";
    Which will add the directory "../lib" relative to where the script is installed (instead of relative to your current directory) to @INC.