Rename your B package to anything else and it works perfectly.

use NEXT; package A; sub A::method { print "$_[0]: A method\n"; $_[0]->NEXT::method() } sub A::DESTROY { print "$_[0]: A dtor\n"; $_[0]->NEXT::DESTROY() } package Ba; use base qw( A ); sub Ba::AUTOLOAD { print "$_[0]: B AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub Ba::DESTROY { print "$_[0]: B dtor\n"; $_[0]->NEXT::DESTROY() } package C; sub C::method { print "$_[0]: C method\n"; $_[0]->NEXT::method() } sub C::AUTOLOAD { print "$_[0]: C AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub C::DESTROY { print "$_[0]: C dtor\n"; $_[0]->NEXT::DESTROY() } package D; use base qw( Ba C ); sub D::method { print "$_[0]: D method\n"; $_[0]->NEXT::method() } sub D::AUTOLOAD { print "$_[0]: D AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub D::DESTROY { print "$_[0]: D dtor\n"; $_[0]->NEXT::DESTROY() } package main; my $obj = bless {}, "D"; $obj->method(); # Calls D::method, A::method, C::method $obj->missing_method(); # Calls D::AUTOLOAD, B::AUTOLOAD, C::AUTOLO +AD # Clean-up calls D::DESTROY, B::DESTROY, A::DESTROY, C::DESTROY --- D=HASH(0x811b15c): D method D=HASH(0x811b15c): A method D=HASH(0x811b15c): C method D=HASH(0x811b15c): D AUTOLOAD D=HASH(0x811b15c): B AUTOLOAD D=HASH(0x811b15c): C AUTOLOAD D=HASH(0x811b15c): D dtor D=HASH(0x811b15c): B dtor D=HASH(0x811b15c): A dtor D=HASH(0x811b15c): C dtor

B has special meaning to perl and you shouldn't name any package as such.

Update: Fooled myself. Basically, what really happens is that use base qw(B C) loads up B.pm which resets @ISA to Exporter. Note that merely changing the use base qw( A ); line to @ISA = "A"; will make the code work the way you want. Of course, base will still load up B.pm and B.pm's loading will set @B::ISA but since @ISA is defined at runtime, everything will work as expected. So there you have it, base is loading up B. If you wish to not touch B.pm at all, you can switch all use base statements to just set @ISA directly or you can create a BEGIN block in which you define either $INC{"B.pm"} or $B::VERSION.


In reply to Re: Is Conway's NEXT.pm broken? by !1
in thread Is Conway's NEXT.pm broken? by jkeenan1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.