@INC
とuse
ステートメントのパス要素に応じて、シンボルをインポートする際に問題が発生します。perl: `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
#-------------------------------------------------
は私のミスは何ですか?
迅速な返信をありがとうございます。しかし、なぜ私は以前にこの問題がなかったのか分かりません。私は非常に多くのモジュールを持っています。 g。パッケージ名FotoArchiveとFotoが@INCパスにないlib/Fotoの 'FotoArchive.pm'。なぜ私はFoto :: FotoArchiveを介してそれらを呼び出すと、同じ問題が発生しませんか? - ああ、彼らは何も輸出していないので、私は見始める。だから私は間違って私のことを気づいていない。ありがとうございました! – Sadko