™.. diagnostics - Online Linux Manual PageSection : 3pm
Updated : 2009-02-26
Source : perl v5.10.1
Note : Perl Programmers Reference Guide
NAMEdiagnostics, splain − produce verbose warning diagnostics
SYNOPSISUsing the \*(C`diagnostics\*(C'\fR pragma: use diagnostics;
use diagnostics −verbose;
enable diagnostics;
disable diagnostics;
Using the \*(C`splain\*(C'\fR standalone filter program: perl program 2>diag.out
splain [−v] [−p] diag.out
Using diagnostics to get stack traces from a misbehaving script: perl −Mdiagnostics=−traceonly my_script.pl
DESCRIPTION
The diagnostics PragmaThis module extends the terse diagnostics normally emitted by both the perl compiler and the perl interpreter (from running perl with a −w switch or \*(C`use warnings\*(C'\fR), augmenting them with the more explicative and endearing descriptions found in perldiag. Like the other pragmata, it affects the compilation phase of your program rather than merely the execution phase. To use in your program as a pragma, merely invoke use diagnostics;
at the start (or near the start) of your program. (Note that this does enable perl's −w flag.) Your whole compilation will then be subject(ed :−) to the enhanced diagnostics. These still go out STDERR. Due to the interaction between runtime and compiletime issues, and because it's probably not a very good idea anyway, you may not use \*(C`no diagnostics\*(C'\fR to turn them off at compiletime. However, you may control their behaviour at runtime using the disable() and enable() methods to turn them off and on respectively. The −verbose flag first prints out the perldiag introduction before any other diagnostics. The $diagnostics::PRETTY variable can generate nicer escape sequences for pagers. Warnings dispatched from perl itself (or more accurately, those that match descriptions found in perldiag) are only displayed once (no duplicate descriptions). User code generated warnings a la warn() are unaffected, allowing duplicate user messages to be displayed. This module also adds a stack trace to the error message when perl dies. This is useful for pinpointing what caused the death. The −traceonly (or just −t) flag turns off the explanations of warning messages leaving just the stack traces. So if your script is dieing, run it again with perl −Mdiagnostics=−traceonly my_bad_script
to see the call stack at the time of death. By supplying the −warntrace (or just −w) flag, any warnings emitted will also come with a stack trace.
The splain ProgramWhile apparently a whole nuther program, splain is actually nothing more than a link to the (executable) diagnostics.pm module, as well as a link to the diagnostics.pod documentation. The −v flag is like the \*(C`use diagnostics \-verbose\*(C'\fR directive. The −p flag is like the $diagnostics::PRETTY variable. Since you're post-processing with splain, there's no sense in being able to enable() or disable() processing. Output from splain is directed to STDOUT, unlike the pragma.
EXAMPLESThe following file is certain to trigger a few errors at both runtime and compiletime: use diagnostics;
print NOWHERE "nothing\n";
print STDERR "\n\tThis message should be unadorned.\n";
warn "\tThis is a user warning";
print "\nDIAGNOSTIC TESTER: Please enter a <CR> here: ";
my $a, $b = scalar <STDIN>;
print "\n";
print $x/$y;
If you prefer to run your program first and look at its problem afterwards, do this: perl −w test.pl 2>test.out
./splain < test.out
Note that this is not in general possible in shells of more dubious heritage, as the theoretical (perl −w test.pl >/dev/tty) >& test.out
./splain < test.out
Because you just moved the existing stdout to somewhere else. If you don't want to modify your source code, but still have on-the-fly warnings, do this: exec 3>&1; perl −w test.pl 2>&1 1>&3 3>&− | splain 1>&2 3>&−
Nifty, eh? If you want to control warnings on the fly, do something like this. Make sure you do the \*(C`use\*(C'\fR first, or you won't be able to get at the enable() or disable() methods. use diagnostics; # checks entire compilation phase
print "\ntime for 1st bogus diags: SQUAWKINGS\n";
print BOGUS1 'nada';
print "done with 1st bogus\n";
disable diagnostics; # only turns off runtime warnings
print "\ntime for 2nd bogus: (squelched)\n";
print BOGUS2 'nada';
print "done with 2nd bogus\n";
enable diagnostics; # turns back on runtime warnings
print "\ntime for 3rd bogus: SQUAWKINGS\n";
print BOGUS3 'nada';
print "done with 3rd bogus\n";
disable diagnostics;
print "\ntime for 4th bogus: (squelched)\n";
print BOGUS4 'nada';
print "done with 4th bogus\n";
INTERNALSDiagnostic messages derive from the perldiag.pod file when available at runtime. Otherwise, they may be embedded in the file itself when the splain package is built. See the Makefile for details. If an extant $SIG{_ _WARN_ _} handler is discovered, it will continue to be honored, but only after the diagnostics::splainthis() function (the module's $SIG{_ _WARN_ _} interceptor) has had its way with your warnings. There is a $diagnostics::DEBUG variable you may set if you're desperately curious what sorts of things are being intercepted. BEGIN { $diagnostics::DEBUG = 1 }
BUGSNot being able to say ‟no diagnostics” is annoying, but may not be insurmountable. The \*(C`\-pretty\*(C'\fR directive is called too late to affect matters. You have to do this instead, and before you load the module. BEGIN { $diagnostics::PRETTY = 1 }
I could start up faster by delaying compilation until it should be needed, but this gets a ‟panic: top_level” when using the pragma form in Perl 5.001e. While it's true that this documentation is somewhat subserious, if you use a program named splain, you should expect a bit of whimsy.
AUTHORTom Christiansen <tchrist@mox.perl.com>, 25 June 1995. 0
Johanes Gumabo
Data Size : 21,861 byte
man-diagnostics.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 181,763
Visitor ID : :
Visitor IP : 3.147.42.34 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|diagnostics.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|diagnostics.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|diagnostics.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|diagnostics.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|diagnostics.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|diagnostics.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|diagnostics.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|diagnostics.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|diagnostics.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|249|diagnostics.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|diagnostics.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|diagnostics.3pm|136|\*(C`diagnostics\*(C'\fR pragma: |Using the \f(CW\*(C`diagnostics\*(C'\fR pragma:
) (rof_escape_sequence|91|diagnostics.3pm|146|\*(C`splain\*(C'\fR standalone filter program: |Using the \f(CW\*(C`splain\*(C'\fR standalone filter program:
) (rof_escape_sequence|91|diagnostics.3pm|165|\*(C`use warnings\*(C'\fR), augmenting them with the more |switch or \f(CW\*(C`use warnings\*(C'\fR), augmenting them with the more
) (rof_escape_sequence|91|diagnostics.3pm|183|\*(C`no diagnostics\*(C'\fR to turn them off at compiletime. |you may not use \f(CW\*(C`no diagnostics\*(C'\fR to turn them off at compiletime.
) (rof_escape_sequence|91|diagnostics.3pm|213|\*(C`use diagnostics \-verbose\*(C'\fR directive. |the \f(CW\*(C`use diagnostics \-verbose\*(C'\fR directive.
) (rof_escape_sequence|91|diagnostics.3pm|263|\*(C`use\*(C'\fR first, or you won't be able to get |Make sure you do the \f(CW\*(C`use\*(C'\fR first, or you won't be able to get
) (rof_escape_sequence|91|diagnostics.3pm|309|\*(C`\-pretty\*(C'\fR directive is called too late to affect matters. |The \f(CW\*(C`\-pretty\*(C'\fR directive is called too late to affect matters.
)