Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Tie & Destroy, OOP

by bikeNomad (Priest)
on Aug 09, 2001 at 21:34 UTC ( #103521=note: print w/replies, xml ) Need Help??


in reply to Tie & Destroy, OOP

If you get rid of your objects before global destruction time, you won't have these problems. One solution is just to make sure that the objects are in an inner lexical scope:

{ my $global = ...; sub doSomething { $global->whatever() } }
Another solution is to deliberately clear object references in an END block:

use strict; $^W++; $|++; package A; sub new { my $self = bless {}, $_[0]; print "construct $self\n"; $self; } # Package destructor sub END { print "in global destruction\n"; } # Object destructor sub DESTROY { print "destroying $_[0]\n"; } package main; our $a = A->new(); END { $a = undef; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://103521]
help
Chatterbox?
[1nickt]: Thank you haukex and hippo. I'm thinking of using IPC::System:: Simple::capture instead. But will go reread Hauke's treatise first :-)
[1nickt]: herveus is so weird. Love his reply in that SQLite thread! Much more effective warning system to have diverse monks debunk on technical merits...
[haukex]: IPC::System:: Simple does all the $? handling for you, and does it well
[erix]: weird problem btw (that SQLite question) - I asked astroboy to let us know if he finds the cause
[hippo]: The syntax is warning enough to me.
[1nickt]: hippo lately I can tell just by the fact that Anonymous posts a reply after some hours that it is more than likely That Monk.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-12-13 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (360 votes). Check out past polls.

    Notices?