我有一个 perl 问题:导入符号,具体取决于路径元素@INC
和use
语句。
如果我将完整路径放入@INC
,则导入有效。如果路径的一部分在use
语句中,则执行要导入的模块,但必须显式完成导入:
########################################
# @INC has: "D:/plu/lib/"
#------------------------------------------------
# Exporting file is here: "D:/plu/lib/impex/ex.pm"
#
use strict;
use warnings;
package ex;
use Exporter;
our @ISA = 'Exporter';
our @EXPORT = qw( fnQuark );
sub fnQuark { print "functional quark\n"; }
print "Executing module 'ex'\n";
1;
#------------------------------------------------
# Importing file, example 1, is here: "D:/plu/lib/impex/imp.pl"
#
use strict;
use warnings;
package imp;
use impex::ex;
ex->import( @ex::EXPORT ); # removing this line makes fnQuark unavailable!
# Why is this necessary, 'ex.pm' being an Exporter?
fnQuark();
#------------------------------------------------
# Importing file, example 2, is here: "D:/plu/lib/impex/imp2.pl"
#
use strict;
use warnings;
package imp2;
use lib 'D:/plu/lib/impex';
use ex;
fnQuark(); # works without explicit import
#-------------------------------------------------
我的错误是什么?