0

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)?

Developus
  • 1,400
  • 2
  • 14
  • 50

1 Answers1

5

I think what you're looking for is FindBin.

Specifically:

use FindBin qw( );
use lib $FindBin::RealBin."/utils"; 
use content; 
ikegami
  • 367,544
  • 15
  • 269
  • 518
Sobrique
  • 52,974
  • 7
  • 60
  • 101