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

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;

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |