Bootstrap FreeKB - Perl (Scripting) - Resolve "Can't locate Example.pm in @INC" in Perl
Perl (Scripting) - Resolve "Can't locate Example.pm in @INC" in Perl

Updated:   |  Perl (Scripting) articles

Let's say you have a module named foo.pm. In this example, on a Linux system, the module is located at /usr/shared/perl/modules/foo.pm.

/usr/share/perl/modules/foo.pm

 

Or you may be using a module that you installed from cpan. For example, let's say you installed the Net::SSH::Perl module.

Let's say you have a Perl script named bar.pl that wants to use the foo.pm and Net::SSH::Perl modules.

#!/usr/bin/perl
use strict;
use warnings;
use foo;
use Net::SSH::Perl;

 

Let's say you invoke bar. pl . . 

perl bar.pl

 

. . . and the following is returned. Notice in this example that /usr/share/perl/modules is not included.

Can't locate foo.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at bar.pl line 4.

 

One option here is to include use lib followed by the directory that contains the module in your Perl script.

#!/usr/bin/perl
use strict;
use warnings;
use lib "/usr/share/perl/modules";
use foo;

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 6a8217 in the box below so that we can be sure you are a human.