in reply to Re: Overriding of a method
in thread Overriding of a method

Thanks for replies. Unfortunately I have asked the question incorrectly. Is it a method which allows not to change code in my modules for the call MIME::Lite->send() method.(i.e. use MIME::Lite rather than My::MIME::Lite)?

Replies are listed 'Best First'.
Re^3: Overriding of a method
by Nomad (Pilgrim) on Nov 30, 2005 at 18:37 UTC

    Yes. You can directly insert your new method into the symbol table. But it is not recommended. It makes your code hard to follow, hard to debug and unpredictable. Do you know for example what methods inside Mime::Lite might be expecting the 'send' method to have the documented behaviour? Are there other modules you are using that expect Mime::Lite::send to have the documented behaviour?

    Besides all that, it's ugly.

    But if I haven't put you off by my little rant above and you still want do to it, here is one of the ways:

    *MIME::Lite::send = sub { ... your code here ....}

    Update: Of course, another way of doing it is at the bottom of jhourcle's post.