develooper Front page | perl.perl5.porters | Postings from May 2003

Re: [perl #22291] 5.8.x: no warnings "redefine" doesn't affect constant subs

Thread Previous
From:
Stas Bekman
Date:
May 25, 2003 16:13
Subject:
Re: [perl #22291] 5.8.x: no warnings "redefine" doesn't affect constant subs
Message ID:
3ED14DFE.4060904@stason.org
Rafael Garcia-Suarez wrote:
> Stas Bekman wrote:
> 
>>However I'd very much like to have a mechanism to shut this warning up. The 
>>reason: if you are using Apache::Reload while developing mod_perl modules, 
>>inability of shutting down this warnings forces you to avoid the usage of 
>>constants, because you want to keep your error log free of useless (for 
>>development purpose) clutter. I want to be able to shut those down, and I'm 
>>aware of the consequences. It sounds like a not perl-ish way, if you can't 
>>make perl quiet.
> 
> 
> You can always trap warnings via $SIG{__WARN__}.
> 
> The problem with Apache::Reload is that it may leave around some modules
> compiled with the old constant, and compile newer ones with the new value
> of the constant. (Remember that constants are inlined.) That's why I'm
> not confortable with having this warning easy to disable.

Certainly, I wasn't looking for an easy one.

> (Maybe an ad-hoc optional $SIG{__WARN__} handler could go
> into Apache::Reload ?)

Looks like this one works:

...
local $SIG{__WARN__} = \&skip_redefine_warn;
require $key;
...

sub skip_redefine_warn {
     return if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/;
     CORE::warn(@_);
}

I'll add a special config option which will enable this feature for those who 
know what they are doing.

Thanks for the hint Rafael.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About