in reply to Re: DESTROY problem
in thread DESTROY problem

My understanding is that a module must be explicitly (Update: although perhaps indirectly) loaded via use, require or do for any name collision to occur.

The example code of the OP seems to have been changed in some way to make it 'clearer', and the exact invocation of the program is not given, but no such loading of the B module seems to have been done, so no name collision could happen.

Replies are listed 'Best First'.
Re^3: DESTROY problem
by Anonymous Monk on Dec 31, 2010 at 20:54 UTC
    See this
    $ perl -le"print for grep /^\w+::/, keys %:: version:: Tie:: utf8:: re:: CORE:: DynaLoader:: mro:: Win32CORE:: attributes:: Regexp:: UNIVERSAL:: main:: Win32:: PerlIO:: IO:: Internals:: DB::
    Its not inconceivable that B could be loaded without an explicit use B;

      I get the same output if I change the class name:

      use strict; use warnings; use 5.010; {package Dog; sub new { my $class = shift; bless {}, $class; } sub DESTROY { my $self = shift; say "destroy"; $self->SUPER::DESTROY; } } my $d = Dog->new; --output:-- destroy (in cleanup) Can't locate object method "DESTROY" via package +"Dog" at perl2.pl line 16.

      I ran the program like this:

      C:\Users\Me\Documents>perl perl2.pl

      I'll follow JavaFan's instructions--rather than Randall Scwhartz's.