Skip to content

Commit c0c8dd5

Browse files
committed
getopt.pl: add getopts usage.
1 parent b2356ce commit c0c8dd5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: getopt.pl

+26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
###################################################################
2222

2323
use strict;
24+
use File::Basename;
2425
use Getopt::Long;
2526

2627
# test some modules installed or not.
@@ -33,6 +34,7 @@ BEGIN
3334
}
3435
}
3536

37+
my $script = File::Basename::basename($0);
3638
my @libs = ();
3739
my %flags = ();
3840
my ( $verbose, $all, $more, $debug, $test);
@@ -49,6 +51,30 @@ BEGIN
4951
);
5052

5153

54+
use Getopt::Std qw( getopts );
55+
56+
my %opts;
57+
58+
getopts("a:dhl:p:t:uk", \%opts)
59+
or die &usage();
60+
61+
if ($opts{h}) {
62+
print &usage();
63+
exit;
64+
}
65+
66+
sub usage {
67+
return <<'_EOC_';
68+
Usage:
69+
$script [optoins]
70+
71+
Options:
72+
-h Print this usage.
73+
74+
Examples:
75+
$script -h
76+
_EOC_
77+
}
5278
### $verbose
5379
### $more
5480
### $debug

0 commit comments

Comments
 (0)