-4

i have a directory with main.pl and Product.pl. in the main.pl i try to import the Product class but the execution fails when i run perl main.pl complaining that cant locate Product.pm in @INC. My directory is not in the @INC list. How can i fix this?

b10n1k
  • 567
  • 5
  • 21
  • The duplicate question's answers don't really answer this, so my answer is to use [lib::relative](https://metacpan.org/pod/lib::relative) or the mechanism described in its docs. – Grinnz Dec 02 '19 at 16:53

2 Answers2

1

Create a local subdirectory, name it lib and put your module file there. On newer Perls you must tell Perl to include that local directory to @INC, either by adding it to PERL5LIB (environment variable) somehow, or by adding

use lib qw( . );

to the script that wants to load that module. If you are paranoid you can also use an absolute path.

Holli
  • 5,072
  • 10
  • 27
0

You already got some help in complain that module's filename should end in .pm. Now you need to look for the purpose of variable PERL5LIB=???.

PERL5LIB

Polar Bear
  • 6,762
  • 1
  • 5
  • 12