in reply to DESTROY not defined error

This is because DESTROY is implicitly called upon the destruction of the object, and because you've defined an AUTOLOAD method, that's trying to deal with it but failing since DESTROY hasn't been defined. If you add a dummy method the error will go away e.g
sub DESTROY { }
See. perlobj for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: DESTROY not defined error
by bronto (Priest) on Jan 23, 2004 at 11:12 UTC

    Right

    It's a general rule that when you do OO-Perl and you use an AUTOLOAD method you should always explicitly define a DESTROY method as well (unless AUTOLOAD takes care of DESTROY, too); even an empty one.

    Another trick that you could use to speed up things is to have AUTOLOAD install a method in the package namespace each time it is called. This was a trick that TheDamian explained in his book "Object Oriented Perl". Take a look at this node by Ovid to see how (or buy the book ;)

    Ciao!
    --bronto


    The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
    --John M. Dlugosz
Re: Re: DESTROY not defined error
by ysth (Canon) on Jan 23, 2004 at 11:43 UTC
    Note that if it doesn't find a DESTROY method for an object, perl doesn't mind; perl only calls DESTROY if it appears to exist. And if you have an AUTOLOAD method, perl (intentionally) will find that when looking for a DESTROY.

    (For what it's worth, the import and unimport methods implicitly called by use and no don't work this way; if they don't exist but AUTOLOAD does, AUTOLOAD isn't called.)