diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | lib/MDK/Common/Func.pm | 20 |
2 files changed, 10 insertions, 12 deletions
@@ -1,3 +1,5 @@ +- modify before_leaving() to be compatible with perl 5.10.0 + Version 1.2.9 - 11 September 2007, by Thierry Vignaud - fix including the doc of sub-modules diff --git a/lib/MDK/Common/Func.pm b/lib/MDK/Common/Func.pm index 82811bb..cccaadc 100644 --- a/lib/MDK/Common/Func.pm +++ b/lib/MDK/Common/Func.pm @@ -286,20 +286,16 @@ sub partition(&@) { sub add_f4before_leaving { my ($f, $b, $name) = @_; - unless ($MDK::Common::Func::before_leaving::{$name}) { + $MDK::Common::Func::before_leaving::_list->{$b}{$name} = $f; + if (!$MDK::Common::Func::before_leaving::_added{$name}) { + $MDK::Common::Func::before_leaving::_added{$name} = 1; no strict 'refs'; - ${"MDK::Common::Func::before_leaving::$name"} = 1; - ${"MDK::Common::Func::before_leaving::list"} = 1; + *{"MDK::Common::Func::before_leaving::$name"} = sub { + my $f = $MDK::Common::Func::before_leaving::_list->{$_[0]}{$name} or die ''; + $name eq 'DESTROY' and delete $MDK::Common::Func::before_leaving::_list->{$_[0]}; + &$f; + }; } - local *N = *{$MDK::Common::Func::before_leaving::{$name}}; - my $list = *MDK::Common::Func::before_leaving::list; - $list->{$b}{$name} = $f; - *N = sub { - my $f = $list->{$_[0]}{$name} or die ''; - $name eq 'DESTROY' and delete $list->{$_[0]}; - &$f; - } if !defined &{*N}; - } #- ! the functions are not called in the order wanted, in case of multiple before_leaving :( |