2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>warnings - Perl pragma to control optional warnings
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> warnings - Perl pragma to control optional warnings
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#synopsis">SYNOPSIS
</a></li>
24 <li><a href=
"#description">DESCRIPTION
</a></li>
31 <h1><a name=
"name">NAME
</a></h1>
32 <p>warnings - Perl pragma to control optional warnings
</p>
36 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
41 use warnings
"all
";
42 no warnings
"all
";
</pre>
44 use warnings::register;
45 if (warnings::enabled()) {
46 warnings::warn(
"some warning
");
49 if (warnings::enabled(
"void
")) {
50 warnings::warn(
"void
",
"some warning
");
53 if (warnings::enabled($object)) {
54 warnings::warn($object,
"some warning
");
57 warnings::warnif(
"some warning
");
58 warnings::warnif(
"void
",
"some warning
");
59 warnings::warnif($object,
"some warning
");
</pre>
63 <h1><a name=
"description">DESCRIPTION
</a></h1>
64 <p>The
<code>warnings
</code> pragma is a replacement for the command line flag
<code>-w
</code>,
65 but the pragma is limited to the enclosing block, while the flag is global.
66 See
<a href=
"file://C|\msysgit\mingw\html/pod/perllexwarn.html">the perllexwarn manpage
</a> for more information.
</p>
67 <p>If no import list is supplied, all possible warnings are either enabled
69 <p>A number of functions are provided to assist module authors.
</p>
71 <dt><strong><a name=
"item_use_warnings_3a_3aregister">use warnings::register
</a></strong>
74 <p>Creates a new warnings category with the same name as the package where
75 the call to the pragma is used.
</p>
78 <dt><strong><a name=
"item_enabled">warnings::enabled()
</a></strong>
81 <p>Use the warnings category with the same name as the current package.
</p>
84 <p>Return TRUE if that warnings category is enabled in the calling module.
85 Otherwise returns FALSE.
</p>
88 <dt><strong>warnings::enabled($category)
</strong>
91 <p>Return TRUE if the warnings category,
<code>$category
</code>, is enabled in the
93 Otherwise returns FALSE.
</p>
96 <dt><strong>warnings::enabled($object)
</strong>
99 <p>Use the name of the class for the object reference,
<code>$object
</code>, as the
100 warnings category.
</p>
103 <p>Return TRUE if that warnings category is enabled in the first scope
104 where the object is used.
105 Otherwise returns FALSE.
</p>
108 <dt><strong><a name=
"item_warn">warnings::warn($message)
</a></strong>
111 <p>Print
<code>$message
</code> to STDERR.
</p>
114 <p>Use the warnings category with the same name as the current package.
</p>
117 <p>If that warnings category has been set to ``FATAL'' in the calling module
118 then die. Otherwise return.
</p>
121 <dt><strong>warnings::warn($category, $message)
</strong>
124 <p>Print
<code>$message
</code> to STDERR.
</p>
127 <p>If the warnings category,
<code>$category
</code>, has been set to ``FATAL'' in the
128 calling module then die. Otherwise return.
</p>
131 <dt><strong>warnings::warn($object, $message)
</strong>
134 <p>Print
<code>$message
</code> to STDERR.
</p>
137 <p>Use the name of the class for the object reference,
<code>$object
</code>, as the
138 warnings category.
</p>
141 <p>If that warnings category has been set to ``FATAL'' in the scope where
<code>$object
</code>
142 is first used then die. Otherwise return.
</p>
145 <dt><strong><a name=
"item_warnif">warnings::warnif($message)
</a></strong>
148 <p>Equivalent to:
</p>
152 if (warnings::enabled())
153 { warnings::warn($message) }
</pre>
156 <dt><strong>warnings::warnif($category, $message)
</strong>
159 <p>Equivalent to:
</p>
163 if (warnings::enabled($category))
164 { warnings::warn($category, $message) }
</pre>
167 <dt><strong>warnings::warnif($object, $message)
</strong>
170 <p>Equivalent to:
</p>
174 if (warnings::enabled($object))
175 { warnings::warn($object, $message) }
</pre>
179 <p>See
<a href=
"file://C|\msysgit\mingw\html/pod/perlmodlib.html#pragmatic_modules">Pragmatic Modules in the perlmodlib manpage
</a> and
<a href=
"file://C|\msysgit\mingw\html/pod/perllexwarn.html">the perllexwarn manpage
</a>.
</p>
180 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
181 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
182 <big><strong><span class=
"block"> warnings - Perl pragma to control optional warnings
</span></strong></big>