On 15 March 2015 at 20:07, Manfred Lotz <manfred.l...@arcor.de> wrote:

> I prefer the method Charles showed. But nevertheless your method is
> interesting as well.
>

FWIW, SIG{__WARN__} is much preferred over redirecting stderr to simply
suppress/capture/filter warnings.

For instance, if somebody passes an object to warn, context will not be
captured if you're piping STDERR.

And capturing STDERR has side effects, and potential complications.

With SIG{__WARN__}, you can at least observe the warning, and reemit it.

See `perldoc -f warn` for details.

But SIG{__WARN__} very much was designed with the purpose of processing
warnings.

And if you just want to silence them, you can do $SIG{__WARN__} = "IGNORE";

Just make sure you use local so you don't mess up other peoples warn
handlers in higher contexts when you're done.

-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

Reply via email to