in reply to Can I use the OO DESTROY method ... for a good cause

Keep in mind that I'm fairly new to Perl myself, but...

...from what I know, the best course of action is to simply let the garbage collector do its work. Declare $MIMEobject as a lexical variable inside your if() { ... } block; once it goes out of scope and once there are no references to it anymore, the garbage collector will automatically reclaim it. There's no need to explicitely call DESTROY.

If you want to release it ASAP, you could also undef it.

May the more enlightened monks correct me if I'm wrong!

  • Comment on Re: Can I use the OO DESTROY method ... for a good cause

Replies are listed 'Best First'.
Re^2: Can I use the OO DESTROY method ... for a good cause
by kennethk (Abbot) on Jul 22, 2014 at 21:53 UTC

    This is correct; you should never explicitly invoke DESTROY, it will be called once the reverence reference count goes to zero. If you need to explicitly invoke DESTROY, you're doing it wrong.

    Update: Facepalm. Well spotted, Your Mother.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Reverence count? The monastery has gone to your head. :P