On Mon, Mar 27, 2006 at 01:07:48PM -0500, John Peacock wrote: > Nick Ing-Simmons wrote: > >use looks for %INC entry to see if it is already loaded > > Ah ha! That's the ticket. For future references, this is the block of > code that I added (watch wrapping): > > +BEGIN { > + # Perl 5.005_x doesn't support lexical warnings, so we > + # do the next best thing and mess with the global $SIG{__WARN__} > + # handler to hide the "mandatory" warnings > + if ( $] < 5.006 ) { > + my $warnings = <<""; > + package warnings; > + # this evil^Wclever bit courtesy of Nick Ing-Simmons > + \$INC{'warnings.pm'} = "inline"; > + sub unimport { > + shift; # ignore the package name > + my \@warnings = \@_; > + my \$warnregex = '('.join('|',\@warnings).')'; > + \$SIG{__WARN__} = sub { warn \$_[0] unless \$_[0] =~ > /\$warnregex/ }; > + } > + 1; > + > + eval $warnings; > + die $@ if $@; > + } > +} Um. If this code runs during actual live use of warnings, I don't think you're at liberty to change $SIG{__WARN__}. It may already by in use. Is there a reason for not just changing $^W locally? Or rewriting the warnings-triggering code?Thread Previous | Thread Next