1warnings(3pm)          Perl Programmers Reference Guide          warnings(3pm)
2
3
4

NAME

6       warnings - Perl pragma to control optional warnings
7

SYNOPSIS

9           use warnings;
10           no warnings;
11
12           use warnings "all";
13           no warnings "all";
14
15           use warnings::register;
16           if (warnings::enabled()) {
17               warnings::warn("some warning");
18           }
19
20           if (warnings::enabled("void")) {
21               warnings::warn("void", "some warning");
22           }
23
24           if (warnings::enabled($object)) {
25               warnings::warn($object, "some warning");
26           }
27
28           warnings::warnif("some warning");
29           warnings::warnif("void", "some warning");
30           warnings::warnif($object, "some warning");
31

DESCRIPTION

33       The "warnings" pragma is a replacement for the command line flag "-w",
34       but the pragma is limited to the enclosing block, while the flag is
35       global.  See perllexwarn for more information.
36
37       If no import list is supplied, all possible warnings are either enabled
38       or disabled.
39
40       A number of functions are provided to assist module authors.
41
42       use warnings::register
43           Creates a new warnings category with the same name as the package
44           where the call to the pragma is used.
45
46       warnings::enabled()
47           Use the warnings category with the same name as the current
48           package.
49
50           Return TRUE if that warnings category is enabled in the calling
51           module.  Otherwise returns FALSE.
52
53       warnings::enabled($category)
54           Return TRUE if the warnings category, $category, is enabled in the
55           calling module.  Otherwise returns FALSE.
56
57       warnings::enabled($object)
58           Use the name of the class for the object reference, $object, as the
59           warnings category.
60
61           Return TRUE if that warnings category is enabled in the first scope
62           where the object is used.  Otherwise returns FALSE.
63
64       warnings::fatal_enabled()
65           Return TRUE if the warnings category with the same name as the
66           current package has been set to FATAL in the calling module.
67           Otherwise returns FALSE.
68
69       warnings::fatal_enabled($category)
70           Return TRUE if the warnings category $category has been set to
71           FATAL in the calling module.  Otherwise returns FALSE.
72
73       warnings::fatal_enabled($object)
74           Use the name of the class for the object reference, $object, as the
75           warnings category.
76
77           Return TRUE if that warnings category has been set to FATAL in the
78           first scope where the object is used.  Otherwise returns FALSE.
79
80       warnings::warn($message)
81           Print $message to STDERR.
82
83           Use the warnings category with the same name as the current
84           package.
85
86           If that warnings category has been set to "FATAL" in the calling
87           module then die. Otherwise return.
88
89       warnings::warn($category, $message)
90           Print $message to STDERR.
91
92           If the warnings category, $category, has been set to "FATAL" in the
93           calling module then die. Otherwise return.
94
95       warnings::warn($object, $message)
96           Print $message to STDERR.
97
98           Use the name of the class for the object reference, $object, as the
99           warnings category.
100
101           If that warnings category has been set to "FATAL" in the scope
102           where $object is first used then die. Otherwise return.
103
104       warnings::warnif($message)
105           Equivalent to:
106
107               if (warnings::enabled())
108                 { warnings::warn($message) }
109
110       warnings::warnif($category, $message)
111           Equivalent to:
112
113               if (warnings::enabled($category))
114                 { warnings::warn($category, $message) }
115
116       warnings::warnif($object, $message)
117           Equivalent to:
118
119               if (warnings::enabled($object))
120                 { warnings::warn($object, $message) }
121
122       See "Pragmatic Modules" in perlmodlib and perllexwarn.
123
124
125
126perl v5.12.4                      2011-06-07                     warnings(3pm)
Impressum