.pm ファイルの使用方法を学ぼうとしています。2 つのファイルを作成しました。
MyScript.pl
use strict; BEGIN { unshift(@INC,"./firstdir"); } my @list = qw (J u s t ~ A n o t h e r ~ P e r l ~ H a c k e r !); use seconddir::MyModule qw(func1) ; print func1(@list),"\n"; #line 21 print MyModule::func2(@list),"\n";
MyModule.pm
package MyModule; use strict; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(func1 func2); %EXPORT_TAGS = ( DEFAULT => [qw(&func1)], Both => [qw(&func1 &func2)]); sub func1 { return reverse @_ } sub func2 { return map{ uc }@_ } 1;
ディレクトリの構造は次のとおりです。
--------------- ------------ ---------------
| firstdir ---|------> |seconddir--|-> | MyModule.pm |
| MyScript.pl | ------------ ---------------
---------------
注: コマンドを実行すると、firstdir と seconddir はディレクトリでありPerl MyScript.pl
、次のエラーが表示されます。
Undefined subroutine &main::func1 called at MyScript.pl line 21
何が間違っているのかを理解するのを手伝ってもらえますか?