#!/bin/sh # -*-Perl-*- # Next line prepares PATH for being extended. case "$PATH" in *:) ;; *) PATH="$PATH:";; esac # Next line shows how to augment PATH so that this program will work # also on machines where Perl is in a strange location. PATH="${PATH}/usr/local/bin:/usr/local/bin/apps" export PATH exec perl -w -CSDA -S -x -- "$0" "$@" #!perl -w -CSDA # See "man perlrun" for the full details of the meaning of -CSDA, # which turns on UTF-8 processing. In recent Perl versions, it must # appear both on the real command-line and also in the (fake) #!perl # line. # To prevent Emacs's indentation code from trying to parse the stuff # above. (); # The 1st, 5th, and 6th lines above are a hack to make this script # work regardless of where Perl is installed. We can count on sh # being installed at /bin/sh, but we can not count on Perl being # installed at /usr/bin/perl or anywhere else. This method assumes # that "perl" is in the user's PATH or is in one of the directories # being added to the PATH. The hack here is similar to hacks # described in the perlrun(1) man page. The key difference is the use # of the -x option together with the bogus "#!perl -w" line. # # The switches to Perl are as follows (see "man perlrun" for full # explanations): # # -S Search for the script in PATH if it does not begin with /. # -x Skip lines in script until line beginning with #! and # containing "perl". Note that Perl will always (regardless # of whether -x option specified) add any additional options # specified on such a line at the beginning of a script. # -w Turn on compilation warnings. # -CSDA Specify UTF-8 encoding for file descriptors 0, 1, 2 (S), for # any subsequently opened files (D), and for command-line # arguments (A), regardless of locale. In recent Perl # versions, this must appear both on the real command-line and # also in the (fake) #!perl line. # -- No more options after this. The next argument will be # interpreted as a script to run. Any subsequent arguments # will be assigned to @ARGV in that script. # # Note that sh will expand "$@" to _zero_ words if no arguments were # given. # The suggestion in perlrun(1) to make the first line “#!/bin/sh -- # # -*- perl -*- -w” does not work under Linux 2.0.30 due to quirks of # the way Linux 2.0.30 handles the #! line. Specifically, it puts “-- # # -*- perl -*- -w” into a single argument to /bin/sh, which of # course /bin/sh barfs on. I hesitate to call this a bug in Linux due # to the lack of a standard on the #! line, but I think it is supposed # to just use the “--” portion, ignoring everything after the second # space. # $Id: perl-template,v 1.16 2017/06/03 22:57:17 jbw Exp $ use English; # Unfortunately, contrary to the documentation, the connection between # $_ and $ARG that the English module claims to establish is # unreliable. The problem seems to be due to strange interactions # with "foreach" and may be dependent on the version of Perl. It is # best to avoid the use of $ARG. The connection between the other # special variables and their nice names probably works fine. use warnings; # Does the same as the -w command-line option. use strict; use Getopt::Long; # PROGRAM GOES HERE my $Short_Prog_Name = $PROGRAM_NAME; $Short_Prog_Name =~ s(.*/)(); sub show_version { print STDERR '$Id: perl-template,v 1.16 2017/06/03 22:57:17 jbw Exp $', "\n"; } sub show_help { print STDERR "Usage: $Short_Prog_Name [OPTION]... ****FILLTHISIN****...\n"; print STDERR "Try `perldoc $Short_Prog_Name' for more information.\n"; print STDERR "If that fails, try `perldoc $PROGRAM_NAME'.\n"; } sub debug_print { #print STDERR "$Short_Prog_Name: @_\n"; } my ($Show_Help, $Show_Version); my %Options = ( "help" => \$Show_Help, "version" => \$Show_Version, ); if (! GetOptions (%Options)) { show_help(); exit 1; } show_version() if $Show_Version; show_help() if $Show_Help; exit 0 if ($Show_Version || $Show_Help); =head1 NAME ***PROGRAMNAME*** - ***PROGRAMDESCRIPTION*** =head1 SYNOPSIS B<***PROGRAMNAME***> [I