in reply to autoflush and 'DESTROY'

Add the line:

sub DESTROY {}

to the Chatbot::Eliza code to fix the warning. For some background on DESTROY see Object scope and DESTROY

From perlman:perltoot:

Destruction happens automatically via Perl's garbage collection (GC) system, which is a quick but somewhat lazy reference-based GC system. To know what to call, Perl insists that the destructor be named DESTROY. Perl's notion of the right time to call a destructor is not well-defined currently, which is why your destructors should not rely on when they are called.

Evidently autoflush is altering when DESTROY is called. I recall reading somewhere that you should include a DESTROY() method to avoid warnings like this but can't remember where for the life of me.

cheers

tachyon

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

Replies are listed 'Best First'.
Re: Re: autoflush and 'DESTROY'
by Juerd (Abbot) on Mar 16, 2002 at 21:00 UTC

    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
    

      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