Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: why am I getting odd behavior on DESTROY

by einhverfr (Friar)
on Mar 20, 2015 at 13:28 UTC ( [id://1120743]=note: print w/replies, xml ) Need Help??


in reply to Re: why am I getting odd behavior on DESTROY
in thread why am I getting odd behavior on DESTROY

As a note, if anyone needs an example of why use strict is so important even for little things, this is a pretty good example and I will not be unhappy if you share it as an example of what not to do.
  • Comment on Re^2: why am I getting odd behavior on DESTROY

Replies are listed 'Best First'.
Re^3: why am I getting odd behavior on DESTROY
by einhverfr (Friar) on Mar 23, 2015 at 10:26 UTC

    As a quick write-up as to why this happens and why use strict helps here:

    The destructor reassigns the garbage-collected object to a global package variable, whichof course cancels the destruction. The next one gets copied over the existing package variable, which of course throws the first object back into garbage collection, which gets copied over the package variable, etc. in a loop.

    What is suprising here si that Perl doesn't go into an endless loop. Naturally this is hard to debug using standard tools because it is not a misnamed variable but a side effect of a scoping error. Strict prevents this sort of error.

    Again, anyone wants to use it for presentations or anything regarding why strict, feel free.

Re^3: why am I getting odd behavior on DESTROY
by marinersk (Priest) on Mar 20, 2015 at 14:41 UTC

    If I could triple ++ this post I would. Out with the Ego, in with the Honest Man.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1120743]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found