On Sat, 13 May 2000 12:22:10 -0500, Aaron <[EMAIL PROTECTED]> wrote:
>I was under the impression that the reason for using
>"my" to declare a variable was to make it act like a
>local variable in a sub-routine or loop. Once you
>leave the sub or loop, the variable ceases to exist,
>thus making your script more efficient, easier to
>debug, and more flexible.
>
>But, I have yet to understand what the benefit of
>using my on, what I would consider to be, "global"
>variables. Won't the vars in the "main" part of the
>script get destroyed upon completion?
>
>Alas...I suppose some caring person may wish to impart
>this knowledge to me. :)
Unfortunately, the global destruction phase of Perl is highly fragile. It
is very much possible that the DESTROY method for objects stored in global
variables will not be called. This problem has been known for a very long
time (5 years or so), but is hard or maybe even impossible to fix
completely. Therefore it is often advisable to store objects in lexical
variables, even at file scope. Cleanup of lexical variables happens in a
predictable manner (when the scope is closed). Even for file scopes, this
is well before global interpreter shutdown.
Please note that all objects somehow caught in a circular reference chain
share the unpredictable destruction behavior of objects stored in the
symbol table.
-Jan
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]