3 sub _getglob { \*{$_[0]} }
4 sub _getstash { \%{"$_[0]::"} }
7 *lt_5_8_3 = $] < 5.008003
14 use Module::Runtime qw(require_module);
15 use base qw(Exporter);
19 _getglob _install_modifier _load_module _maybe_load_module
23 sub _install_modifier {
24 my ($into, $type, $name, $code) = @_;
26 if (my $to_modify = $into->can($name)) { # CMM will throw for us if not
28 Sub::Defer::undefer_sub($to_modify);
31 Class::Method::Modifiers::install_modifier(@_);
37 (my $proto = $_[0]) =~ s/::/\//g;
38 return 1 if $INC{"${proto}.pm"};
39 # can't just ->can('can') because a sub-package Foo::Bar::Baz
40 # creates a 'Baz::' key in Foo::Bar's symbol table
41 return 1 if grep !/::$/, keys %{_getstash($_[0])||{}};
42 require_module($_[0]);
46 sub _maybe_load_module {
47 return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
48 (my $proto = $_[0]) =~ s/::/\//g;
50 if (eval { require "${proto}.pm"; 1 }) {
51 $MAYBE_LOADED{$_[0]} = 1;
53 if (exists $INC{"${proto}.pm"}) {
54 warn "$_[0] exists but failed to load with error: $@";
56 $MAYBE_LOADED{$_[0]} = 0;
58 return $MAYBE_LOADED{$_[0]};
62 return mro::get_linear_isa($_[0]);
65 our $_in_global_destruction = 0;
66 END { $_in_global_destruction = 1 }
68 sub STANDARD_DESTROY {
75 $self->DEMOLISHALL($_in_global_destruction);
81 die $e if $e; # rethrow