Created
July 12, 2009 02:00
-
-
Save lestrrat/145482 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
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - lestrrat | |
# http://d.hatena.ne.jp/bingo_nakanishi_perl/20090711/1247331243 | |
package Bar; | |
use Moose; | |
has name => (is => 'ro'); | |
sub say { | |
my $self = shift; | |
print $self->name, "です\n"; | |
} | |
package main; | |
use strict; | |
my $bar = Bar->new(name => "パー"); | |
$bar->say(); | |
$bar->meta->add_method(say2 => sub { | |
my $self = shift; | |
print $self->name, "やがな\n"; | |
}); | |
$bar->say2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment