1warnings(3pm) Perl Programmers Reference Guide warnings(3pm)
2
3
4
6 warnings - Perl pragma to control optional warnings
7
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
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 pack‐
48 age.
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::warn($message)
65 Print $message to STDERR.
66
67 Use the warnings category with the same name as the current pack‐
68 age.
69
70 If that warnings category has been set to "FATAL" in the calling
71 module then die. Otherwise return.
72
73 warnings::warn($category, $message)
74 Print $message to STDERR.
75
76 If the warnings category, $category, has been set to "FATAL" in the
77 calling module then die. Otherwise return.
78
79 warnings::warn($object, $message)
80 Print $message to STDERR.
81
82 Use the name of the class for the object reference, $object, as the
83 warnings category.
84
85 If that warnings category has been set to "FATAL" in the scope
86 where $object is first used then die. Otherwise return.
87
88 warnings::warnif($message)
89 Equivalent to:
90
91 if (warnings::enabled())
92 { warnings::warn($message) }
93
94 warnings::warnif($category, $message)
95 Equivalent to:
96
97 if (warnings::enabled($category))
98 { warnings::warn($category, $message) }
99
100 warnings::warnif($object, $message)
101 Equivalent to:
102
103 if (warnings::enabled($object))
104 { warnings::warn($object, $message) }
105
106 See "Pragmatic Modules" in perlmodlib and perllexwarn.
107
108
109
110perl v5.8.8 2001-09-21 warnings(3pm)