我有以下perl模块:
#!/usr/bin/env perl
package temp;
require Exporter;
our @ISA = ('Exporter');
our @EXPORT = qw(temp_print);
sub temp_print {
my ($p) = @_ ;
print "$pn" ;
}
1;
此文件在这里存在:./f/temp.pm我的主文件称为test.pl,看起来像这个
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib $Bin;
use f::temp ;
temp_print("hi");
当我尝试执行test.pl时,它似乎并没有将temp_print导入主要软件包:
% ./test.pl
Undefined subroutine &main::temp_print called at ./test.pl line 8.
我不确定我缺少什么。这似乎是基本的,但似乎无法弄清楚为什么我的软件包中的子例程没有被导入。你能帮我弄清楚怎么了吗?
use Exporter ...
是
BEGIN {
require Exporter;
Exporter->import(...);
}
通过说require Exporter
,您正在跳过呼叫Exporter
的import
方法。
您还必须将正确的软件包/文件名问题整理为ZDIM的评论。