Skip to content

Instantly share code, notes, and snippets.

@riywo
Created October 6, 2011 06:26
Show Gist options
  • Save riywo/1266665 to your computer and use it in GitHub Desktop.
Save riywo/1266665 to your computer and use it in GitHub Desktop.
perlで別のモジュールのメソッドを生やす その2
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;
package Hoge2;
use strict;
use warnings;
sub hoge {
my $c = shift;
print $c->{'foo'} . "\n";
}
1;
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