X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FGlobalDestruction.pm;h=97eedd0e56c13d23eb60b51a50dc808d6980f217;hb=09b1281346cf3f556c319aed994f0dd305eaad63;hp=9378650ba4aff08eee2928c2ab3be4e15a36271d;hpb=23d57d814f3de626fe938d6502bb37b489ebd75a;p=p5sagit%2FDevel-GlobalDestruction.git diff --git a/lib/Devel/GlobalDestruction.pm b/lib/Devel/GlobalDestruction.pm index 9378650..97eedd0 100644 --- a/lib/Devel/GlobalDestruction.pm +++ b/lib/Devel/GlobalDestruction.pm @@ -25,6 +25,33 @@ elsif (eval { }) { # the eval already installed everything, nothing to do } +# We need pure-perl and we are running under -c +# None of the END-block trickery will work, use a global scope guard instead, +# as it is more than adequate in this situation +# The whole thing is in an eval to prevent perl from parsing it in the +# first place where none of this is needed +# +elsif ($^C) { + eval <<'PP_IGD' or die $@; + + my $in_global_destruction; + + sub in_global_destruction () { $in_global_destruction } + + { + package Devel::GlobalDestgruction::_MinusC::ScopeGuard; + sub DESTROY { shift->[0]->() }; + } + + no warnings 'once'; + $Devel::GlobalDestgruction::_MinusC::guard = bless [sub { + $in_global_destruction = 1; + }], 'Devel::GlobalDestgruction::_MinusC::ScopeGuard'; + + 1; # keep eval happy + +PP_IGD +} # Not core nor XS # The whole thing is in an eval to prevent perl from parsing it in the # first place under perls where none of this is needed