I'm willing to bet your signal handler is being overwritten by someone else. To find out what is stomping on your __WARN__ handler, tie the signal handler hash to a simple Tie::StdHash with a bit of reporting to see where else people are changing $SIG{__WARN__}.

Here is my solutino that will find you where your __WARN__ handle is getting overwritten.

TheLoader.pm
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;
BTW, this was tested with blah.pl:
use strict; use warnings; use Bar; use Foo; foo(); warn "hi"; Foo::bar(); warn "hi";
Foo.pm
package Foo; sub bar { $SIG{__WARN__} = sub { 0; }; } 1;
And Bar.pm
use strict; use warnings; package Bar; use TheLoader; foo(); warn "hi"; warn "inherited AUTOLOAD here";
When run here, blah.pl gives:
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

In reply to Re: handling __WARN__ funkiness by cazz
in thread handling __WARN__ funkiness by xevian

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.