/bin/cat << EndTemplate
#!/usr/bin/perl
#<@FILENAME@: do something

use Modern::Perl;
use Getopt::Long;
use File::Basename;
use version; our \$VERSION = qv((qw\$Revision: 1.1 \$)[-1]);

local \$ENV{'PATH'} = join ":", qw(/usr/local/bin /bin /usr/bin);

my \$debug = 0;    # debug on or off.
my \$bytes = 1;    # show default plus required value for an option.

sub parse_args {
    local @ARGV = @_ if @_;

    my (\$help, \$man, \$uuid, \$version, \$where);
    my %opts = (
        bytes   => \\\$bytes,
        debug   => \\\$debug,
        help    => \\\$help,
        manpage => \\\$man,
        uuid    => \\\$uuid,
        version => \\\$version,
        where   => \\\$where
        );

    GetOptions(
        \%opts, 'bytes=i', 'debug', 'help|?', 'manpage',
        'uuid', 'version', 'where'
      )
      or exit(1);

    if (\$help) {
        my (\$emsg) = @_;
        require Pod::Usage;     # avoid conditional "use": PBP
        Pod::Usage->import(qw(pod2usage));
        warn "\$emsg\n" if defined \$emsg;
        pod2usage(-verbose => 99, -sections => "NAME|SYNOPSIS|OPTIONS");
    }

    if (\$man) {
        local \$ENV{"PERLDOC_PAGER"} = 'less';
        my @args = ("perldoc", "\$0");
        exec {\$args[0]} @args;    # safe even with one-arg list
        die "should not get here\n";
    }

    if (\$uuid) {
        my \$UUID = (qw\$UUID: $(uuidgen) \$)[-1];
        print "\$UUID\n";
        exit(0);
    }

    if (\$version) {
        my \$myname = basename(\$0);
        \$myname =~ s{\. [^.]+ \z}{}xms; # strip any extension

        my \$DATE = join(" ",
            (qw\$Date: 2000-01-01 00:00:01-05 \$)[-2 .. -1]);
        print "\$myname \$VERSION \$DATE\n";
        exit(0);
    }

    if (\$where) {
        no warnings 'qw'; ## no critic (TestingAndDebugging::ProhibitNoWarnings)
        my \$SOURCE = (qw\$Source: $PWD \$)[-1];
        my \$HOST   = (qw\$Host: $(hostname).$DOMAIN \$)[-1];
        print "file://\$HOST", "\$SOURCE\n";
        exit(0);
    }

    return(@ARGV);
}

sub main {
    local @ARGV = @_ if @_;
    @ARGV = parse_args(@ARGV);

    unless (@ARGV) {    # stdin
        if (-f STDIN || -p STDIN) {
            push @ARGV, '-' ;
        }   
        else {
            die "need something to read\n";
        }   
    }   

    foreach my \$f (@ARGV) {
        my \$fh;
        if (\$f eq '-') {
            \$fh = \*STDIN;
        }
        else {
            open(\$fh, '<', \$f) or die "\$f: can't open: \$!\n";
        }

        # do stuff with the file
        print "FILE: [\$f]\n" if \$debug;
        while (<\$fh>) {
            chomp;
            print "[\$_]\n";
        }
        close(\$fh);
    }

    exit(0);
}

main() if not caller();

__END__
=head1 NAME

@FILENAME@: do something

=head1 SYNOPSIS

@FILENAME@ [-huvw] [file ...]

=head1 OPTIONS

=over 4

=item B<-h>

Print a brief help message and exit.

=item B<-u>

Print the script UUID and exit.

=item B<-v>

Print the version and exit.

=item B<-w>

Print the canonical source location and exit.

=back

=head1 DESCRIPTION

Does something really cool.

=cut
EndTemplate
