warnings - Perl pragma to control optional warnings
use warnings; no warnings; use warnings "all"; no warnings "all"; use warnings::register; if (warnings::enabled()) { warnings::warn("some warning"); } if (warnings::enabled("void")) { warnings::warn("void", "some warning"); } if (warnings::enabled($object)) { warnings::warn($object, "some warning"); } warnings::warnif("some warning"); warnings::warnif("void", "some warning"); warnings::warnif($object, "some warning");
The warnings pragma is a replacement for the command line flag -w, but the pragma is limited to the enclosing block, while the flag is global. See perllexwarn for more information and the list of built-in warning categories.
warnings
-w
If no import list is supplied, all possible warnings are either enabled or disabled.
A number of functions are provided to assist module authors.
Creates a new warnings category with the same name as the package where the call to the pragma is used.
Use the warnings category with the same name as the current package.
Return TRUE if that warnings category is enabled in the calling module. Otherwise returns FALSE.
Return TRUE if the warnings category, $category, is enabled in the calling module. Otherwise returns FALSE.
$category
Use the name of the class for the object reference, $object, as the warnings category.
$object
Return TRUE if that warnings category is enabled in the first scope where the object is used. Otherwise returns FALSE.
Return TRUE if the warnings category with the same name as the current package has been set to FATAL in the calling module. Otherwise returns FALSE.
Return TRUE if the warnings category $category has been set to FATAL in the calling module. Otherwise returns FALSE.
Return TRUE if that warnings category has been set to FATAL in the first scope where the object is used. Otherwise returns FALSE.
Print $message to STDERR.
$message
If that warnings category has been set to "FATAL" in the calling module then die. Otherwise return.
If the warnings category, $category, has been set to "FATAL" in the calling module then die. Otherwise return.
If that warnings category has been set to "FATAL" in the scope where $object is first used then die. Otherwise return.
Equivalent to:
if (warnings::enabled()) { warnings::warn($message) }
if (warnings::enabled($category)) { warnings::warn($category, $message) }
if (warnings::enabled($object)) { warnings::warn($object, $message) }
This registers warning categories for the given names and is primarily for use by the warnings::register pragma, for which see perllexwarn.
See "Pragmatic Modules" in perlmodlib and perllexwarn.
To install P5re, copy and paste the appropriate command in to your terminal.
cpanm
cpanm P5re
CPAN shell
perl -MCPAN -e shell install P5re
For more information on module installation, please visit the detailed CPAN module installation guide.