3 no warnings 'once'; # guard against -w
5 sub _getglob { \*{$_[0]} }
6 sub _getstash { \%{"$_[0]::"} }
9 *lt_5_8_3 = $] < 5.008003
16 use Module::Runtime qw(require_module);
17 use base qw(Exporter);
21 _getglob _install_modifier _load_module _maybe_load_module
25 sub _install_modifier {
26 my ($into, $type, $name, $code) = @_;
28 if (my $to_modify = $into->can($name)) { # CMM will throw for us if not
30 Sub::Defer::undefer_sub($to_modify);
33 Class::Method::Modifiers::install_modifier(@_);
39 (my $proto = $_[0]) =~ s/::/\//g;
40 return 1 if $INC{"${proto}.pm"};
41 # can't just ->can('can') because a sub-package Foo::Bar::Baz
42 # creates a 'Baz::' key in Foo::Bar's symbol table
43 return 1 if grep !/::$/, keys %{_getstash($_[0])||{}};
44 require_module($_[0]);
48 sub _maybe_load_module {
49 return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
50 (my $proto = $_[0]) =~ s/::/\//g;
52 if (eval { require "${proto}.pm"; 1 }) {
53 $MAYBE_LOADED{$_[0]} = 1;
55 if (exists $INC{"${proto}.pm"}) {
56 warn "$_[0] exists but failed to load with error: $@";
58 $MAYBE_LOADED{$_[0]} = 0;
60 return $MAYBE_LOADED{$_[0]};
64 return mro::get_linear_isa($_[0]);
67 our $_in_global_destruction = 0;
68 END { $_in_global_destruction = 1 }
70 sub STANDARD_DESTROY {
77 $self->DEMOLISHALL($_in_global_destruction);
83 die $e if $e; # rethrow