Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: The correct way to redefine a routineby jsegal (Friar) |
on Apr 02, 2008 at 22:27 UTC ( [id://678057]=note: print w/replies, xml ) | Need Help?? |
Like many things in Perl, there is more than one way to do it. Others in this thread have suggesting subclassing, which sometimes works, sometimes doesn't. For instance, suppose you are using class A which instantiates class B, and it is the method in class B that you need to override, even for your use of class A. Though you could in theory override class A to have the method in question instantiate your overriding class B, perl does let you do change class B's method directly.
Be warned that doing this sort of thing may be fraught with danger, especially if you upgrade the class whose method you are overriding, or if other classes you use call that method and depend on the old behavior. But if you go in with your eyes open and are aware of these issues, here are a couple of other ways to meet this goal:
--JAS
In Section
Seekers of Perl Wisdom
|
|