|No such thing as a small change|
Hijacking a methodby Transient (Hermit)
|on Jun 17, 2009 at 16:27 UTC||Need Help??|
Transient has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to hijack an object's method to do some logging around it. I'm modifying some legacy code, and could simply call the logging functions around each call to the object's method, but I'm lazy. I also don't have (and don't want) explicit access to the object's method code - I don't want to mess up the internals.
Basically,I have this:
and the end result might be this:
My gut reaction is to go with symbol tables, but I'm unsure of how to proceed. I am also wondering how I would reference the outside object (in this case, the $myFunkyLogMachine object) inside the changed sub.
My initial thoughts were something like:
but I have a feeling that isn't anywhere close to correct.
Thanks in advance for any help.