Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "SPLAIN 1" | |
132 | .TH SPLAIN 1 "2007-06-19" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | diagnostics, splain \- produce verbose warning diagnostics | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | Using the \f(CW\*(C`diagnostics\*(C'\fR pragma: | |
138 | .PP | |
139 | .Vb 2 | |
140 | \& use diagnostics; | |
141 | \& use diagnostics -verbose; | |
142 | .Ve | |
143 | .PP | |
144 | .Vb 2 | |
145 | \& enable diagnostics; | |
146 | \& disable diagnostics; | |
147 | .Ve | |
148 | .PP | |
149 | Using the \f(CW\*(C`splain\*(C'\fR standalone filter program: | |
150 | .PP | |
151 | .Vb 2 | |
152 | \& perl program 2>diag.out | |
153 | \& splain [-v] [-p] diag.out | |
154 | .Ve | |
155 | .PP | |
156 | Using diagnostics to get stack traces from a misbehaving script: | |
157 | .PP | |
158 | .Vb 1 | |
159 | \& perl -Mdiagnostics=-traceonly my_script.pl | |
160 | .Ve | |
161 | .SH "DESCRIPTION" | |
162 | .IX Header "DESCRIPTION" | |
163 | .ie n .Sh "The ""diagnostics"" Pragma" | |
164 | .el .Sh "The \f(CWdiagnostics\fP Pragma" | |
165 | .IX Subsection "The diagnostics Pragma" | |
166 | This module extends the terse diagnostics normally emitted by both the | |
167 | perl compiler and the perl interpreter (from running perl with a \-w | |
168 | switch or \f(CW\*(C`use warnings\*(C'\fR), augmenting them with the more | |
169 | explicative and endearing descriptions found in perldiag. Like the | |
170 | other pragmata, it affects the compilation phase of your program rather | |
171 | than merely the execution phase. | |
172 | .PP | |
173 | To use in your program as a pragma, merely invoke | |
174 | .PP | |
175 | .Vb 1 | |
176 | \& use diagnostics; | |
177 | .Ve | |
178 | .PP | |
179 | at the start (or near the start) of your program. (Note | |
180 | that this \fIdoes\fR enable perl's \fB\-w\fR flag.) Your whole | |
181 | compilation will then be subject(ed :\-) to the enhanced diagnostics. | |
182 | These still go out \fB\s-1STDERR\s0\fR. | |
183 | .PP | |
184 | Due to the interaction between runtime and compiletime issues, | |
185 | and because it's probably not a very good idea anyway, | |
186 | you may not use \f(CW\*(C`no diagnostics\*(C'\fR to turn them off at compiletime. | |
187 | However, you may control their behaviour at runtime using the | |
188 | \&\fIdisable()\fR and \fIenable()\fR methods to turn them off and on respectively. | |
189 | .PP | |
190 | The \fB\-verbose\fR flag first prints out the perldiag introduction before | |
191 | any other diagnostics. The \f(CW$diagnostics::PRETTY\fR variable can generate nicer | |
192 | escape sequences for pagers. | |
193 | .PP | |
194 | Warnings dispatched from perl itself (or more accurately, those that match | |
195 | descriptions found in perldiag) are only displayed once (no duplicate | |
196 | descriptions). User code generated warnings a la \fIwarn()\fR are unaffected, | |
197 | allowing duplicate user messages to be displayed. | |
198 | .PP | |
199 | This module also adds a stack trace to the error message when perl dies. | |
200 | This is useful for pinpointing what caused the death. The \fB\-traceonly\fR (or | |
201 | just \fB\-t\fR) flag turns off the explanations of warning messages leaving just | |
202 | the stack traces. So if your script is dieing, run it again with | |
203 | .PP | |
204 | .Vb 1 | |
205 | \& perl -Mdiagnostics=-traceonly my_bad_script | |
206 | .Ve | |
207 | .PP | |
208 | to see the call stack at the time of death. By supplying the \fB\-warntrace\fR | |
209 | (or just \fB\-w\fR) flag, any warnings emitted will also come with a stack | |
210 | trace. | |
211 | .Sh "The \fIsplain\fP Program" | |
212 | .IX Subsection "The splain Program" | |
213 | While apparently a whole nuther program, \fIsplain\fR is actually nothing | |
214 | more than a link to the (executable) \fIdiagnostics.pm\fR module, as well as | |
215 | a link to the \fIdiagnostics.pod\fR documentation. The \fB\-v\fR flag is like | |
216 | the \f(CW\*(C`use diagnostics \-verbose\*(C'\fR directive. | |
217 | The \fB\-p\fR flag is like the | |
218 | \&\f(CW$diagnostics::PRETTY\fR variable. Since you're post-processing with | |
219 | \&\fIsplain\fR, there's no sense in being able to \fIenable()\fR or \fIdisable()\fR processing. | |
220 | .PP | |
221 | Output from \fIsplain\fR is directed to \fB\s-1STDOUT\s0\fR, unlike the pragma. | |
222 | .SH "EXAMPLES" | |
223 | .IX Header "EXAMPLES" | |
224 | The following file is certain to trigger a few errors at both | |
225 | runtime and compiletime: | |
226 | .PP | |
227 | .Vb 8 | |
228 | \& use diagnostics; | |
229 | \& print NOWHERE "nothing\en"; | |
230 | \& print STDERR "\en\etThis message should be unadorned.\en"; | |
231 | \& warn "\etThis is a user warning"; | |
232 | \& print "\enDIAGNOSTIC TESTER: Please enter a <CR> here: "; | |
233 | \& my $a, $b = scalar <STDIN>; | |
234 | \& print "\en"; | |
235 | \& print $x/$y; | |
236 | .Ve | |
237 | .PP | |
238 | If you prefer to run your program first and look at its problem | |
239 | afterwards, do this: | |
240 | .PP | |
241 | .Vb 2 | |
242 | \& perl -w test.pl 2>test.out | |
243 | \& ./splain < test.out | |
244 | .Ve | |
245 | .PP | |
246 | Note that this is not in general possible in shells of more dubious heritage, | |
247 | as the theoretical | |
248 | .PP | |
249 | .Vb 2 | |
250 | \& (perl -w test.pl >/dev/tty) >& test.out | |
251 | \& ./splain < test.out | |
252 | .Ve | |
253 | .PP | |
254 | Because you just moved the existing \fBstdout\fR to somewhere else. | |
255 | .PP | |
256 | If you don't want to modify your source code, but still have on-the-fly | |
257 | warnings, do this: | |
258 | .PP | |
259 | .Vb 1 | |
260 | \& exec 3>&1; perl -w test.pl 2>&1 1>&3 3>&- | splain 1>&2 3>&- | |
261 | .Ve | |
262 | .PP | |
263 | Nifty, eh? | |
264 | .PP | |
265 | If you want to control warnings on the fly, do something like this. | |
266 | Make sure you do the \f(CW\*(C`use\*(C'\fR first, or you won't be able to get | |
267 | at the \fIenable()\fR or \fIdisable()\fR methods. | |
268 | .PP | |
269 | .Vb 4 | |
270 | \& use diagnostics; # checks entire compilation phase | |
271 | \& print "\entime for 1st bogus diags: SQUAWKINGS\en"; | |
272 | \& print BOGUS1 'nada'; | |
273 | \& print "done with 1st bogus\en"; | |
274 | .Ve | |
275 | .PP | |
276 | .Vb 4 | |
277 | \& disable diagnostics; # only turns off runtime warnings | |
278 | \& print "\entime for 2nd bogus: (squelched)\en"; | |
279 | \& print BOGUS2 'nada'; | |
280 | \& print "done with 2nd bogus\en"; | |
281 | .Ve | |
282 | .PP | |
283 | .Vb 4 | |
284 | \& enable diagnostics; # turns back on runtime warnings | |
285 | \& print "\entime for 3rd bogus: SQUAWKINGS\en"; | |
286 | \& print BOGUS3 'nada'; | |
287 | \& print "done with 3rd bogus\en"; | |
288 | .Ve | |
289 | .PP | |
290 | .Vb 4 | |
291 | \& disable diagnostics; | |
292 | \& print "\entime for 4th bogus: (squelched)\en"; | |
293 | \& print BOGUS4 'nada'; | |
294 | \& print "done with 4th bogus\en"; | |
295 | .Ve | |
296 | .SH "INTERNALS" | |
297 | .IX Header "INTERNALS" | |
298 | Diagnostic messages derive from the \fIperldiag.pod\fR file when available at | |
299 | runtime. Otherwise, they may be embedded in the file itself when the | |
300 | splain package is built. See the \fIMakefile\fR for details. | |
301 | .PP | |
302 | If an extant \f(CW$SIG\fR{_\|_WARN_\|_} handler is discovered, it will continue | |
303 | to be honored, but only after the \fIdiagnostics::splainthis()\fR function | |
304 | (the module's \f(CW$SIG\fR{_\|_WARN_\|_} interceptor) has had its way with your | |
305 | warnings. | |
306 | .PP | |
307 | There is a \f(CW$diagnostics::DEBUG\fR variable you may set if you're desperately | |
308 | curious what sorts of things are being intercepted. | |
309 | .PP | |
310 | .Vb 1 | |
311 | \& BEGIN { $diagnostics::DEBUG = 1 } | |
312 | .Ve | |
313 | .SH "BUGS" | |
314 | .IX Header "BUGS" | |
315 | Not being able to say \*(L"no diagnostics\*(R" is annoying, but may not be | |
316 | insurmountable. | |
317 | .PP | |
318 | The \f(CW\*(C`\-pretty\*(C'\fR directive is called too late to affect matters. | |
319 | You have to do this instead, and \fIbefore\fR you load the module. | |
320 | .PP | |
321 | .Vb 1 | |
322 | \& BEGIN { $diagnostics::PRETTY = 1 } | |
323 | .Ve | |
324 | .PP | |
325 | I could start up faster by delaying compilation until it should be | |
326 | needed, but this gets a \*(L"panic: top_level\*(R" when using the pragma form | |
327 | in Perl 5.001e. | |
328 | .PP | |
329 | While it's true that this documentation is somewhat subserious, if you use | |
330 | a program named \fIsplain\fR, you should expect a bit of whimsy. | |
331 | .SH "AUTHOR" | |
332 | .IX Header "AUTHOR" | |
333 | Tom Christiansen <\fItchrist@mox.perl.com\fR>, 25 June 1995. |