in reply to How to make warnings disappear
In Perl 4, there was no POD. But there was a similar trick for wrapping the documentation up in your program. You would write documentation in troff code. (troff is the unix formatting program that is used to format the man pages.) Then you would embed the troff documentation after the __END__ marker for your program, and add some troff commands at the beginning of your program to tell troff to ignore the rest of the Perl code in between. When you ran your program with Perl, the troff commands would be ignored because they looked like string constants in void context.
The result is that you would have one file which would serve as input to Perl or to troff. If you fed it to Perl, it would run. If you fed it to troff (or to the man program, which is just nroff) you would get formatted documentation out the other side.
But when you ran the program, you wouldn't want to get a warning that the documentation strings were being uselessly used in void context, so strings that begin with "ds", "di", and "ig" were exempted from the warning. "di" diverts input into a nother macro, and "ig tells troff to ignore all the following text until it sees a certain character sequence; that's how troff was told to ignore the Perl code. "dr" doesn't appear to have been used.
The pink camel book contains a program called wrapman, which takes a Perl program and wraps it up with the right troff incantations, and appends a stub man page to it. To see an example of the result, look at the file eg/relink that is still in the Perl source distribution.
Astute readers may realize that arranging a file so that it is syntactically correct in two different languages at the same time is a common trick played by people who like to enter obfuscated code contests. It's probably no coincidence that Larry Wall was a repeat winner in the IOCCC.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: How to make warnings disappear
by Dominus (Parson) on Dec 18, 2000 at 22:09 UTC |