NAME
no::warnings - suppress certain warnings for a dynamic scope
SYNOPSIS
Load the module:
use no::warnings;
Disable all warnings for a dynamic scope:
my $result = no::warnings sub {
...;
};
Disable specific warnings for a dynamic scope:
my $result = no::warnings qr/.../, qr/.../, sub {
...;
};
DESCRIPTION
This module provides a function called `no::warnings` which takes a
coderef optionally preceded by a list of things to match.
If no list is provided, it will run the coderef, ignoring any warnings
that would have otherwise been printed to STDERR, and returns the result
of the coderef.
If a list of warnings to ignore is provided, it will run the coderef,
ignoring any warnings that match the list (see match::simple), and returns
the result of the coderef.
This differs from the standard `no warnings` pragma in that it acts
dynamically instead of lexically, allowing you to suppress the printing of
warnings which come from third-party modules, etc. Internally, it uses
$SIG{__WARN__} but if you already have a handler for `__WARN__`, this
module should be smart enough to work alongside it unless you're doing
something especially odd.
BUGS
Please report any bugs to
<https://github.com/tobyink/p5-no-warnings/issues>.
SEE ALSO
warnings.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the
same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.