in reply to Re: Add current working directory to @INC?
in thread Add current working directory to @INC?
use lib '.';
To be on the safe side, and if you plan on chdirring in your script, it's safer to do
cwd(), short for the "current working directory", is a function in Cwd that returns the absolute path for the current directory, thus ".".use Cwd; use lib cwd;
More flexible still is something like
because this way it's easy to add an absolute path out of a specified relative path, say a subdirectory of the current directory:use File::Spec::Functions 'rel2abs'; use lib rel2abs('.');
use File::Spec::Functions 'rel2abs'; use lib rel2abs('lib');
In general, I prefer to use the functions from File::Spec::Functions, but if you don't use it for anything else, I'd avoid the namespace pollution from importing the sub name, and use the more convoluted syntax using the methods:
use File::Spec; use lib File::Spec->rel2abs('lib');
|
|---|