-
-
Save neguse/11392185 to your computer and use it in GitHub Desktop.
動かない原因がわからない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use h1; | |
use h2; | |
use Data::Dumper; | |
print "h1::\n" . Dumper \%h1::; | |
print "h2::\n" . Dumper \%h2::; | |
h1sub1; | |
h2sub1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package h1; | |
use Exporter 'import'; | |
our @EXPORT = qw( | |
h1sub1 | |
h1sub2 | |
); | |
use h2; | |
sub h1sub1 { | |
h2sub2(); | |
} | |
sub h1sub2 { | |
print("h1sub2"); | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package h2; | |
use Exporter 'import'; | |
our @EXPORT = qw( | |
h2sub1 | |
h2sub2 | |
); | |
use h1; | |
sub h2sub1 { | |
h1sub2(); | |
} | |
sub h2sub2 { | |
print("h2sub2"); | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1:: | |
$VAR1 = { | |
'h1sub1' => *h1::h1sub1, | |
'h2sub2' => *h1::h2sub2, | |
'EXPORT' => *h1::EXPORT, | |
'h1sub2' => *h1::h1sub2, | |
'BEGIN' => *h1::BEGIN, | |
'h2sub1' => *h1::h2sub1, | |
'import' => *h1::import | |
}; | |
h2:: | |
$VAR1 = { | |
'import' => *h2::import, | |
'h2sub1' => *h2::h2sub1, | |
'EXPORT' => *h2::EXPORT, | |
'h1sub2' => *h2::h1sub2, | |
'BEGIN' => *h2::BEGIN, | |
'h2sub2' => *h2::h2sub2 | |
}; | |
Undefined subroutine &h2::h1sub2 called at h2.pm line 13. | |
h2sub2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あらためてドキュメントをよむと、BEGINで@exportのあたりをBEGINで実行すればよいようだった。
http://perldoc.perl.org/Exporter.html#Playing-Safe
Exporter::Easy使うのがお手軽っぽいので、それでやる方向で。