[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: #!/Perl question



Hi,
>>"Joey" == Joey Hess <joey@kitenet.net> writes:

 Joey> eval 'exec perl -S $0 ${1+"$@"}'
 Joey>         if 0;
	
        The following works under more shells (and also is a man page ;-)
 I used to use this as a template perl script with built in man page
 (this was before we had POD and pod2man). This is obsolete, but still
 interestin in that this is a legal sehll, perl, and nroff script.

        manoj

----------------------------------------------------------------------
#!/usr/bin/perl     -- # -*- Mode: Perl -*- #
'di';
'ig00';

"true" || eval 'exec perl -S $0 $argv:q';
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if $running_under_some_shell;
$ENV{'PATH'} = '.:/usr/users2/pilgrim/srivasta/bin:/usr/local/bin:' .
    '/usr/bin/X11:/usr/local/lib/perl/scripts:/usr/local/etc:' .
    '/usr/local/emacs/etc:/proj/bin:/usr/new:/usr/ucb:/bin:' .
    '/usr/bin:/usr/etc:/etc:/usr/games:/usr/hosts';
($MYNAME     = $0) =~ s|.*/||;
$RCSHEADER = '$Header$';        #'
'$Revision$'  =~ /^\$\w+:\s+([.1234567890]+)\s+\$$/;    #'
$VERSION = $1;



# Synopsis:
$Usage = <<END_OF_USAGE;
      usage: $MYNAME 
             [-h --help] This message
END_OF_USAGE
    ;
# >> BEGIN parse options >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #
 [SNIP]
# << END main <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #


########################################################

        # These next few lines are legal in both Perl and Nroff.

.00;            # finish .ig
 
'di             \" finish diversion--previous line must be blank
.nr nl 0-1      \" fake up transition to first page again
.nr % 0         \" start at page 1
'; __END__      #### From here on it's a standard manual page ####
.TH ADD_RCSID 1 "Thu Dec  8 1994" "Project Pilgrim, University of Massachusetts 
at Amherst"
.SH NAME
add_rcsid \- Adds an static constant variable holding the rcs id
.SH SYNOPSIS
.SH DESCRIPTION
.SH OPTIONS
.SH ENVIRONMENT
.SH EXAMPLES
.SH FILES
.SH AUTHOR
Manoj Srivastava Dec
.SH SEE ALSO
.SH DIAGNOSTICS
.SH BUGS

-- 
 Hackers of the world, unite!
Manoj Srivastava   <srivasta@debian.org>  <http://www.debian.org/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E


Reply to: