Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created July 12, 2009 02:00
Show Gist options
  • Save lestrrat/145482 to your computer and use it in GitHub Desktop.
Save lestrrat/145482 to your computer and use it in GitHub Desktop.
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - 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