【发布时间】:2014-12-13 10:10:45
【问题描述】:
我在与要使用它的 Perl 程序相同的目录中创建了一个名为 Base.pm 的模块,但该模块似乎没有被加载。将模块的名称更改为 Base 以外的任何名称,一切正常。 Base.pm 有什么特别之处,如何覆盖这种行为?感谢您提供任何见解。
package Base;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(func);
sub func { return "foo"; }
1;
与
use Base;
print func();
产量
Undefined subroutine &main::func called at test0.pl line 2.
而
package Case;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(func);
sub func { return "foo"; }
1;
与
use Case;
print func();
产量
foo.
【问题讨论】:
-
虽然不是重复的,但this question 与您的情况相关。
标签: perl