Created
October 6, 2011 06:26
-
-
Save riywo/1266665 to your computer and use it in GitHub Desktop.
perlで別のモジュールのメソッドを生やす その2
This file contains hidden or 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 Fuga; | |
use strict; | |
use warnings; | |
use Hoge; | |
use Sub::Install; | |
Sub::Install::install_sub({ code => \&Hoge::hoge }); | |
sub new { | |
my ($class) = @_; | |
my $self = bless {}, $class; | |
$self->{'foo'} = 'bar'; | |
return $self; | |
} | |
1; |
This file contains hidden or 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 Hoge2; | |
use strict; | |
use warnings; | |
sub hoge { | |
my $c = shift; | |
print $c->{'foo'} . "\n"; | |
} | |
1; |
This file contains hidden or 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 strict; | |
use warnings; | |
use Fuga; | |
my $fuga = Fuga->new; | |
$fuga->hoge; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment