X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2Findirect.pm;h=c068be73fa8e42e43bbf961f4343ff698cc3c1ec;hb=12f5aa96d0f4d2275aafa29bc76c96a0d4f215a9;hp=5686fbceca6cb6d03f91853e6cc2ccc7def55c2c;hpb=93b51bb94f31703ed1270b3449dd278d12b209f4;p=perl%2Fmodules%2Findirect.git diff --git a/lib/indirect.pm b/lib/indirect.pm index 5686fbc..c068be7 100644 --- a/lib/indirect.pm +++ b/lib/indirect.pm @@ -57,13 +57,20 @@ BEGIN { } sub import { - $^H{indirect} = undef; + $^H{+(__PACKAGE__)} = undef; + (); } +my $msg = sub { "Indirect call of method \"$_[1]\" on object \"$_[0]\"" }; + sub unimport { (undef, my $type) = @_; $^H |= 0x00020000; - $^H{indirect} = (defined $type and $type eq ':fatal') ? 2 : 1; + my $cb = (defined $type and $type eq ':fatal') + ? sub { die $msg->(@_) } + : sub { warn $msg->(@_) }; + $^H{+(__PACKAGE__)} = _tag($cb); + (); } =head1 CAVEATS