diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-01-18 15:17:29 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-01-18 15:17:29 +0000 |
commit | 383f7c131722213b9c3224313995343bb63313ad (patch) | |
tree | 49f8ea55e7dcc9d0ae228ef14f01bb5b69ba20ef /lib | |
parent | 6a88a12be1cc446745577716f9cfedcfebd15e43 (diff) | |
download | perl-MDK-Common-383f7c131722213b9c3224313995343bb63313ad.tar perl-MDK-Common-383f7c131722213b9c3224313995343bb63313ad.tar.gz perl-MDK-Common-383f7c131722213b9c3224313995343bb63313ad.tar.bz2 perl-MDK-Common-383f7c131722213b9c3224313995343bb63313ad.tar.xz perl-MDK-Common-383f7c131722213b9c3224313995343bb63313ad.zip |
- modify before_leaving() to be compatible with perl 5.10.0
more precisely, rewrite add_f4before_leaving in a different way so that
DESTROY is correctly called when it should
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDK/Common/Func.pm | 20 |
1 files changed, 8 insertions, 12 deletions
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 :( |