From: gfx Date: Sun, 20 Sep 2009 03:13:34 +0000 (+0900) Subject: Save global variables (Mouse/Util.pm) X-Git-Tag: 0.32~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0396a57ff4663622ba6862a3039d05c2514fe4b;p=gitmo%2FMouse.git Save global variables (Mouse/Util.pm) --- diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 8452299..2f10181 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -21,16 +21,17 @@ BEGIN { require mro; $impl = \&mro::get_linear_isa; } else { - my $loaded = do { - local $SIG{__DIE__} = 'DEFAULT'; - eval { require MRO::Compat; 1 }; + my $e = do { + local $@; + eval { require MRO::Compat }; + $@; }; - if ($loaded) { + if (!$e) { $impl = \&mro::get_linear_isa; } else { # VVVVV CODE TAKEN FROM MRO::COMPAT VVVVV - my $code; # this recurses so it isn't pretty - $code = sub { + my $_get_linear_isa_dfs; # this recurses so it isn't pretty + $_get_linear_isa_dfs = sub { no strict 'refs'; my $classname = shift; @@ -38,17 +39,17 @@ BEGIN { my @lin = ($classname); my %stored; foreach my $parent (@{"$classname\::ISA"}) { - my $plin = $code->($parent); - foreach (@$plin) { - next if exists $stored{$_}; - push(@lin, $_); - $stored{$_} = 1; + my $plin = $_get_linear_isa_dfs->($parent); + foreach my $p(@$plin) { + next if exists $stored{$p}; + push(@lin, $p); + $stored{$p} = 1; } } return \@lin; }; # ^^^^^ CODE TAKEN FROM MRO::COMPAT ^^^^^ - $impl = $code; + $impl = $_get_linear_isa_dfs; } }