in reply to Strange code execution with 'AUTOLOAD'

Having run into this yesterday, if you defined AUTOLOAD, you are required to define a DESTROY method in your class (in otherwords, you're getting that error as run-time as the class tries to fully define itself, include DESTROY, and fails). DESTROY is the destructor, and if you do any special resource allocation (opened files, database connections) this is the point where you want to dispose of them. However, if you are only holding data in your class and nothing else, DESTROY can simply be an empty method.

Define this in your class, and you'll find that your class should work now.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
  • Comment on Re: Strange code execution with 'AUTOLOAD'

Replies are listed 'Best First'.
Re: Re: Strange code execution with 'AUTOLOAD'
by nysus (Parson) on Jul 01, 2001 at 22:29 UTC
    Mucho thanks. I'm guessing this is new to 5.6.1, then? It's not mentioned in the Conway book (at least not what I've read so far).

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot";
    $nysus = $PM . $MCF;
    Click here if you love Perl Monks