我需要将所有自定义模块与脚本保存在相同的目录中。
我不断收到此错误,表明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
package Custom::Hash;
我的脚本是early_enrollments_by_term.pl
,居住在/home/pgb2/canvas/canvas-sis-feeds/scripts/
#!/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
任何人都可以说出为什么找不到模块吗?
答案 0 :(得分:4)
尽管您只显示了很少的代码,
问题可能是您声明了$enrollment_type
并尝试使用$employment_type
,而该声明尚未声明
Perl无法找到该模块,是use Custom::Hash
语句会引发错误