in reply to handling __WARN__ funkiness
Here is my solutino that will find you where your __WARN__ handle is getting overwritten.
BTW, this was tested with blah.pl:package Report; use Tie::Hash; our @ISA = 'Tie::StdHash'; sub TIEHASH { my $storage = bless {}, shift; $storage } sub STORE { my ($this, $key, $value) = @_; my (@foo) = caller(); my ($package, $filename, $line) = caller; print STDERR "Storing $key => $value in $this at $package, in $fil +ename on line $line.\n"; $this->{$key} = $value } package TheLoader; use strict; use warnings; tie %SIG, 'Report'; $SIG{__WARN__} = sub { return if $_[0] =~ /inherited AUTOLOAD/; print STDERR 'stolen warn: ' . $_[0]; }; package UNIVERSAL; sub AUTOLOAD { print "AUTOLOAD\n"; } 1;
Foo.pmuse strict; use warnings; use Bar; use Foo; foo(); warn "hi"; Foo::bar(); warn "hi";
And Bar.pmpackage Foo; sub bar { $SIG{__WARN__} = sub { 0; }; } 1;
When run here, blah.pl gives:use strict; use warnings; package Bar; use TheLoader; foo(); warn "hi"; warn "inherited AUTOLOAD here";
Storing __WARN__ => CODE(0x818e988) in Report=HASH(0x818e14c) at TheLo +ader, in TheLoader.pm on line 29. AUTOLOAD stolen warn: hi at Bar.pm line 8. AUTOLOAD stolen warn: hi at blah.pl line 7. Storing __WARN__ => CODE(0x818cf68) in Report=HASH(0x818e14c) at Foo, +in Foo.pm on line 4. AUTOLOAD AUTOLOAD AUTOLOAD
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: handling __WARN__ funkiness
by xevian (Sexton) on Oct 11, 2005 at 14:59 UTC |