Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: adding temporary method to a class

by duckyd (Hermit)
on Sep 20, 2006 at 16:57 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found