繁体   English   中英

Perl在与脚本相同的目录中找不到模块

[英]Perl can't find module listed in same directory as script

我需要将所有自定义模块与脚本保存在相同的目录中。

我不断收到此错误,表明Perl无法“看到”我声明的模块

全局符号“ $ employment_type”要求在Early_enrollments_by_term.pl第260行使用显式包名称。

由于编译错误,中止early_enrollments_by_term.pl的执行。

我的模块是Hash.pm ,位于目录/home/pgb2/canvas/canvas-sis-feeds/scripts/lib/Custom

Hash.pm

package Custom::Hash;

我的脚本是early_enrollments_by_term.pl ,位于/home/pgb2/canvas/canvas-sis-feeds/scripts/

early_enrollments_by_term.pl

#!/usr/bin/perl

use strict;

use DBI;

use lib qw(/home/pgb2/canvas/canvas-sis-feeds/scripts/lib);

use Custom::Hash;

my $enrollment_type = $Custom::Hash::enrollment_hash{$role};  # line 259
print "\nenrollment_type: $employment_type\n";                # line 260

谁能说出为什么找不到模块?

尽管您只显示了很少的代码,但问题可能出在您声明了$enrollment_type并尝试使用$employment_type ,但尚未声明

如果perl找不到模块,则use Custom::Hash语句会引发错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM