Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by einhverfr (Friar)
on Mar 23, 2015 at 10:26 UTC ( [id://1120957]=note: print w/replies, xml ) Need Help??


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

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.

  • Comment on Re^3: why am I getting odd behavior on DESTROY

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-20 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found