#!/usr/bin/env perl use 5.010; use strict; use warnings; package A; sub new { bless {} => $_[0] } sub seen_once { 1 } sub seen_twice { 1 } sub seen_thrice { 1 } package A::B; use parent -norequire => 'A'; sub seen_twice { 1 } sub seen_thrice { 1 } package A::B::C; use parent -norequire => 'A::B'; sub seen_thrice { 1 } package main; use mro; my $instantiation_class = 'A::B::C'; my @methods = qw{seen_once seen_twice seen_thrice seen_never}; my $isa = mro::get_linear_isa($instantiation_class); my %found; say "Instantiation class: $instantiation_class"; my $obj = $instantiation_class->new; say 'Objects blessed into class: ', ref $obj; say 'Method Resolution:'; METHOD: for my $method (@methods) { next METHOD if exists $found{$method}; CLASS: for my $class (@$isa) { { no strict 'refs'; next CLASS unless exists ${$class . '::'}{$method}; } ++$found{$method}; say "$method()\tfound first in $class"; last CLASS; } unless (exists $found{$method}) { say "$method()\tNOT found in OO hierarchy!"; } }