Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: adding temporary method to a class

by duckyd (Hermit)
on Sep 20, 2006 at 16:57 UTC ( #573943=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://573943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2023-06-04 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (22 votes). Check out past polls.

    Notices?