Maybe this is what you want:

#!/usr/bin/perl use strict; use warnings FATAL => 'all'; use 5.009_005; # or MRO::Compat; package MyClassDataHelper; { sub get_all_class_data { my $invocant = shift; my $class = ref( $invocant ) || $invocant; my @all_class_data; { no strict 'refs'; for my $package ( @{ mro::get_linear_isa( $class ) } ) { next unless defined *{"${package}::get_class_data"}{CO +DE}; push @all_class_data, $package->get_class_data; } } return @all_class_data; } } package MyClass::A; { use base qw( MyClassDataHelper ); sub get_class_data { return 'MyClass::A data' } } package MyClass::B; { use base qw( MyClass::A ); sub get_class_data { return 'MyClass::B data' } } package MyClass::C; { use base qw( MyClass::B MyClass::A ); sub get_class_data { return 'MyClass::C data' } } package MyClass::D; { use base qw( MyClass::C MyClass::A MyClass::B ); } # Tests print map { "$_\n" } MyClass::D->get_all_class_data; # Output: # MyClass::C data # MyClass::B data # MyClass::A data print map { "$_\n" } MyClass::C->get_all_class_data; # Output: # MyClass::C data # MyClass::B data # MyClass::A data print map { "$_\n" } MyClass::B->get_all_class_data; # Output: # MyClass::B data # MyClass::A data print map { "$_\n" } MyClass::A->get_all_class_data; # Output: # MyClass::A data

In reply to Re: Recursion up The Inheritance Chain by WizardOfUz
in thread Recursion up The Inheritance Chain by rwadkins

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.