| 1 |
#! /usr/bin/perl |
| 2 |
use warnings; |
| 3 |
use strict; |
| 4 |
use integer; |
| 5 |
use FindBin; |
| 6 |
use lib $FindBin::RealBin; |
| 7 |
use Def; |
| 8 |
|
| 9 |
# This script doesn't do anything but take options and arguments from |
| 10 |
# the command line, so it's not very useful to run it. However, if you |
| 11 |
# are writing a new Perl helper script, this makes a pretty good |
| 12 |
# template to start it with. |
| 13 |
|
| 14 |
our $usage = <<END; |
| 15 |
usage: $0 [-h] [argument]... |
| 16 |
-h print this usage message |
| 17 |
END |
| 18 |
|
| 19 |
# Read command-line arguments and options. |
| 20 |
my @opt; |
| 21 |
my @arg; |
| 22 |
{ |
| 23 |
my $stopopt = ''; |
| 24 |
for ( @ARGV ) { |
| 25 |
if ( $stopopt ) { push @arg, $_ } |
| 26 |
elsif ( $_ eq '-' ) { $stopopt = '1' } |
| 27 |
else { push @{ /^-/ ? \@opt : \@arg }, $_ } |
| 28 |
} |
| 29 |
} |
| 30 |
my %opt = map { my @o = split ''; shift @o; map {$_=>1} @o; } @opt; |
| 31 |
if ( $opt{'?'} || $opt{h} ) { print $usage; exit 0; } |
| 32 |
|
| 33 |
# List the options and arguments. |
| 34 |
print "Options : "; print "[$_] " for sort keys %opt; print "\n"; |
| 35 |
print "Arguments: "; print "[$_] " for @arg; print "\n"; |
| 36 |
|