in reply to Re: autoflush and 'DESTROY'
in thread autoflush and 'DESTROY'

to the Chatbot::Eliza code to fix the warning.

You don't have to modify the module itself for this. Changing the module will bite you when upgrading it.

sub Chatbot::Eliza::DESTROY { }

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Replies are listed 'Best First'.
Re: Re: Re: autoflush and 'DESTROY'
by tachyon (Chancellor) on Mar 16, 2002 at 21:10 UTC

    Or perhaps the more obscure

    *{Chatbot::Eliza::DESTROY} = sub {};

    Have you considered a job with M$ ? Patching the source of the problem and informing the author is better than working around the error IMHO

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Have you considered a job with M$?

      Offense taken. Working around a problem is a great solution if you don't want to mess with the original code. To have maintainable code, I think it's important not to mess with modules that came from CPAN. Of course you could/should drop a note at the author's address, but my experience is that new versions are not released within a month.

      When putting a single line of code in your own script can prevent you from changing the module, I think you should be.

      U28geW91IGNhbiBhbGwgcm90MTMgY
      W5kIHBhY2soKS4gQnV0IGRvIHlvdS
      ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
      geW91IHNlZSBpdD8gIC0tIEp1ZXJk
      

        First no offense was meant, if was a feeble attempt at humour. It seemed funny at the time.

        Secondly the problem is a warning. With your (or my solution) of hacking the modules symbol table you get a new warning as soon as the module is patched with a DESTROY() method vis:

        package Chatbot::Eliza; sub new { bless {}, shift } sub DESTROY {} package Foo; use warnings; sub Chatbot::Eliza::DESTROY {} __DATA__ Subroutine Chatbot::Eliza::DESTROY redefined at script line 9 .

        Thus by patching your code you generate a new warning when the module is eventually patched. Hence my point - fix the problem at its root not the symptom.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

        Of course you could/should drop a note at the author's address, but my experience is that new versions are not released within a month.

        I really depends on the module. Most module author will at least accept a patch and include it in the next version, so you can use the pactched module knowing that the patch will still be applicable in the future. Some authors also maintain a development version of modules, and some just release a new version any time a bug is found.

        So really sending a note to the author is the most efficient, polite, not to mention ethical thing to do, this is what Open-SOurce is all about!