Reputation: 1462
I created a simple perl script which is splited into 2 files - main.pl
and content.pm
The main script is placed in Project
directory and content.pm
(module) is placed in Project/utils
directory. Now I want to use content.pm
in main.pl
I made something like this to use this module:
use Cwd;
use lib Cwd::abs_path(getcwd()."/utils");
use utils::content;
but if I do it this way, I get an error:
Cant locate utils/content.pm in
@INC (you may need to install the utils::content module)
@INC contains: /Perl/utils /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 ...)
at ./main.pl line 10.
Is it possible to run this main.pl script using content.pm with no errors? Maybe I should not use getcwd()
(I think it use a working directory instead of abs_path, but I'm not sure)?
Upvotes: 0
Views: 166
Reputation: 53498
I think what you're looking for is FindBin
.
Specifically:
use FindBin qw( );
use lib $FindBin::RealBin."/utils";
use content;
Upvotes: 5