Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created July 12, 2009 02:19
Show Gist options
  • Save lestrrat/145489 to your computer and use it in GitHub Desktop.
Save lestrrat/145489 to your computer and use it in GitHub Desktop.
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - lestrrat
# http://d.hatena.ne.jp/bingo_nakanishi_perl/20090711/1247331243
package Bar;
use strict;
sub new {
my($class, %args) = @_;
return bless { %args }, $class;
}
sub say {
my $self = shift;
print $self->{name}, "です\n";
}
package main;
my $bar = Bar->new(name => "パー");
$bar->say();
*Bar::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