Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Answer: How do I make a destructor?

( #234053=categorized answer: print w/ replies, xml ) Need Help??

Q&A > object-oriented programming > How do I make a destructor? contributed by nite_man

You can create a descructor like this:
sub DESTROY{ my $self = shift; $self->coun_decr(); bless $self, $ISA[0]; }
But before, you should define a object counter and methods for management it:
my $inst_count = 0; sub get_inst_count { $inst_count } sub _incr_inst_count { ++$inst_count } sub _decr_inst_count { --$inst_count }

Comment on Answer: How do I make a destructor?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-08-01 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls