[comp.lang.perl] Another two language hack

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/20/90)

The following is both a Perl program and its own manual page:
--------------------------------------------------
#!/usr/bin/perl
'di';		# This hack eats all nroff input down to 'di line

print "Howdy, world!\n";

'di
.nr nl 0-1		\" fake up transition to first page again
.nr % 0
';<<'\'\'\'END';	# From here on is a standard manual page, except '''END
.\"	@(#)howdy.1	1.1 (JPL) 7/19/90
.\"
.TH HOWDY 1 "July 19, 1990"
.AT 3
.SH NAME
howdy \- say howdy
.SH SYNOPSIS
.B howdy
.SH DESCRIPTION
.I Howdy
says "Howdy, world!".
.SH EXAMPLE
.IP
.nf
     howdy
     Howdy, world!
.fi
.SH "SEE ALSO"
perl(1),
.SH DIAGNOSTICS
.I Howdy 
has no error messages, only non-error messages.
Well, only one non-error message...
'''END
--------------------------------------------------

It also works with the eval "exec..." hack, as long as you don't
collect more than a line's worth of text before that first 'di.

After the next patch, you'll be able to explicitly end the Perl script
with a ^D or ^Z in the input, so the <<'\'\'\'END' thingie won't be
necessary.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov