http://qs1969.pair.com?node_id=573943


in reply to adding temporary method to a class

If don't want to add the method just locally, you can remove it using undef *Class::method;. Here's an example:
my $foo = Foo->new; *Foo::bar = sub { print "bar\n"; }; $foo->bar(); undef *Foo::bar; $foo->bar(); package Foo; sub new { return bless {}, shift; } 1;
output:
bar Can't locate object method "bar" via package "Foo" at foo.pl line 9.