Skip to content

Instantly share code, notes, and snippets.

@sng2c
Created May 30, 2012 02:16
Show Gist options
  • Save sng2c/2832869 to your computer and use it in GitHub Desktop.
Save sng2c/2832869 to your computer and use it in GitHub Desktop.
moose monkey patch
package Dog;
#use Any::Moose;
use Moose;
sub bark{
my $self = shift;
print $self->word() x 2;
print "\n";
}
sub word{
return "멍";
}
package main;
my $meta = Dog->meta;
$meta->add_override_method_modifier('word',sub{return '냐옹'});
my $d = Dog->new();
$d->bark();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment