splain - standalone program to do the same thing
Aa a program:
diagnostics
PragmaTo use in your program as a pragma, merely invoke
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 no diagnostics
to turn them off at compiletime.
However, you may control there behaviour at runtime using the
disable() and enable() methods to turn them off and on respectively.
The -verbose flag first prints out the the perldiag manpage introduction before any other diagnostics. The $diagnostics::PRETTY can generate nicer escape sequences for pgers.
use diagnostics -verbose
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.
If you prefer to run your program first and look at its problem afterwards, do this:
Note that this is not in general possible in shells of more dubious heritage, as the theorectical
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:
Nifty, eh?
If you want to control warnings on the fly, do something like this.
Make sure you do the use
first, or you won't be able to get
at the enable() or disable() methods.
If an extant $SIG{__WARN__} handler is discovered, it will continue to be honored, but only after the diagnostic::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.
The -pretty
directive is called too late to affect matters.
You have to to this instead, and before you load the module.
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 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.