This is really bad advice. Calling the
DESTROY
method on an object will not clean up its memory and
can cause all sorts of weird problems because you have
invoked the destructor for an object that has not actually
been destroyed. You should
never invoke the
DESTROY method explicitly.
When Perl sees that an object is no longer being used by
anyone, it will reclaim the memory for the object automatically.
Just before it does this, it will call the DESTROY
method automatically, to perform any final cleanup that the
object requires, such as closing any filehandles that it might contain.
If you call DESTROY yourself, you will have an
object in an inconsistent state, because DESTROY
thought that the object was about to be destroyed.
But it was not destroyed, because some part of the program
still has a reference to it;
you called DESTROY permaturely.
And then later, when Perl sees that the object is no longer
useful, it will reclaim the memory for the object and
call DESTROY a second time. This could easily
cause all sorts of havoc because a DESTROY method
is only supposed to be called once.
Finally, you run the risk of a fatal run time error
because not every object has a DESTROY method,
and if you call the DESTROY method on an
object that doesn't have one, your program will die.
Summary: never call $o->DESTROY.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.