On December 15, 2003 04:51 am, Gabor Szabo wrote:
> Recently someone asked what to do with the
> Warnings about "Replacing previous run-mode".
>
> I recently encountered this problem so I added the following
> code to my cgiapp_prerun subroutine.
> (local won't work here as the warning is in the run method of C::A)
>
>
>
> $SIG{__WARN__} = sub {
> if ($_[0] !~ /Replacing previous run-mode/) {
> warn $_[0];
> }
> }; # silence the unnecessary warning about changing run_mode
>
>
> Enjoy or let me know what is the flaw in this.
I like it, although I'd rather see that warning gone from the core
package.
Another alternative is to put in your C::A-derived package:
sub run {
my $self = shift;
local $SIG{__WARN__} = ...;
$self->SUPER::run(@_);
}
This allows you to localise as much as possible. However, given the
design of the framework, I don't see there being much advantage to
this over your solution.
For more robustness, you need to check what the current warn is, and,
if defined, call it instead of "warn $_[0]". But that's probably
overkill for most of us until perl6 where it becomes easy (I think).
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]