Skip to content

Instantly share code, notes, and snippets.

@neguse
Last active August 29, 2015 14:00
Show Gist options
  • Save neguse/11392185 to your computer and use it in GitHub Desktop.
Save neguse/11392185 to your computer and use it in GitHub Desktop.
動かない原因がわからない
use h1;
use h2;
use Data::Dumper;
print "h1::\n" . Dumper \%h1::;
print "h2::\n" . Dumper \%h2::;
h1sub1;
h2sub1;
package h1;
use Exporter 'import';
our @EXPORT = qw(
h1sub1
h1sub2
);
use h2;
sub h1sub1 {
h2sub2();
}
sub h1sub2 {
print("h1sub2");
}
1;
package h2;
use Exporter 'import';
our @EXPORT = qw(
h2sub1
h2sub2
);
use h1;
sub h2sub1 {
h1sub2();
}
sub h2sub2 {
print("h2sub2");
}
1;
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
@neguse
Copy link
Author

neguse commented Apr 29, 2014

あらためてドキュメントをよむと、BEGINで@exportのあたりをBEGINで実行すればよいようだった。
http://perldoc.perl.org/Exporter.html#Playing-Safe
Exporter::Easy使うのがお手軽っぽいので、それでやる方向で。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment