【发布时间】:2018-09-19 20:44:10
【问题描述】:
我有一个从模块运行代码的基本 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 包含 SaticBot::Bot 模块所在的目录,但它找不到它。我真的被难住了。
【问题讨论】:
-
什么是
$FindBin::Bin/SatanicBot?可能和$FindBin::Bin/src/SatanicBot不一样 -
这应该链接到正确的位置,因为 run.pl 已经在 src 目录中。第二个暗示 Bot.pm 位于 satanicBot/src/src/SatanicBot 中。至少它看起来会这样做。
-
提示:
lib是包含模块的目录的常规名称,而不是src。 (bin用于脚本)
标签: perl perl-module