我有一个从模块运行代码的基本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模块所在的目录,但它无法找到它。我很难过。
答案 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