无法在@INC中找到自定义模块

时间:2015-10-07 00:57:21

标签: perl perl-module

我有一个从模块运行代码的基本Perl脚本。切换到新计算机后,我无法再运行此脚本。目录树的设置如下:

SatanicBot
  src
    SatanicBot
      Bot.pm
      Utils.pm
  run.pl <-- The script that uses the module

run.pl中的use语句如下:

use warnings;
use strict;
use diagnostics;

use Bot::BasicBot;

use Cwd qw(abs_path);
use FindBin;
use lib abs_path("$FindBin::Bin/SatanicBot");
# Without this, I get an error that is essentially caused by it not being to find the module.
use SatanicBot::Bot; 

当我运行run.pl时,我收到以下错误:

Can't locate SatanicBot/Bot.pm in @INC (you may need to install the SatanicBot::Bot module) (@INC contains: /Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/darwin-2level /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0 /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/darwin-2level /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0 .) at src/run.pl line 12.

正如您所看到的,它声明@INC包含SatanicBot :: Bot模块所在的目录,但它无法找到它。我很难过。

1 个答案:

答案 0 :(得分:4)

@INC包含:

/Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot

但是要在文件SatanicBot::Bot中找到/Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot/Bot.pm包,您希望@INC包含

/Users/elifoster/Desktop/Dev/SatanicBot/src