7stud has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
According to "Intermediate Perl 2nd":
1) DESTROY is like other method calls: Perl starts at the class of the object and works its way up the inheritance hierarchy until it finds a suitable method. However, unlike other method calls, there's no error if Perl doesn't find a suitable method. (p. 140)
However I get an error when I run this code:
use strict; use warnings; use 5.010; {package B; sub new { my $class = shift; bless {}, $class; } sub DESTROY { my $self = shift; say "destroy"; $self->SUPER::DESTROY; } } --output:-- (in cleanup) Can't locate object method "DESTROY" via package "B" at C +:\Users\Me\Documents\perl2.pl line 17. destroy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DESTROY problem
by JavaFan (Canon) on Dec 31, 2010 at 10:54 UTC | |
by 7stud (Deacon) on Dec 31, 2010 at 22:47 UTC | |
by Mr. Muskrat (Canon) on Jan 01, 2011 at 18:04 UTC | |
by JavaFan (Canon) on Jan 01, 2011 at 19:36 UTC | |
|
Re: DESTROY problem
by Corion (Patriarch) on Dec 31, 2010 at 10:49 UTC | |
by 7stud (Deacon) on Dec 31, 2010 at 10:52 UTC | |
|
Re: DESTROY problem
by chrestomanci (Priest) on Dec 31, 2010 at 16:51 UTC | |
by AnomalousMonk (Archbishop) on Dec 31, 2010 at 18:38 UTC | |
by Anonymous Monk on Dec 31, 2010 at 20:54 UTC | |
by 7stud (Deacon) on Dec 31, 2010 at 22:07 UTC | |
|
Re: DESTROY problem
by ambrus (Abbot) on Jan 01, 2011 at 20:45 UTC |