Commit | Line | Data |
---|---|---|
2d08fc49 JH |
1 | # $Id: newgetopt.pl,v 1.18 2001-09-21 15:34:59+02 jv Exp $ |
2 | ||
3 | # This library is no longer being maintained, and is included for backward | |
4 | # compatibility with Perl 4 programs which may require it. | |
5 | # It is now just a wrapper around the Getopt::Long module. | |
6 | # | |
7 | # In particular, this should not be used as an example of modern Perl | |
8 | # programming techniques. | |
9 | # | |
10 | # Suggested alternative: Getopt::Long | |
352d5a3a | 11 | |
ee0007ab | 12 | { package newgetopt; |
ee0007ab | 13 | |
01e8c204 | 14 | # Values for $order. See GNU getopt.c for details. |
15 | $REQUIRE_ORDER = 0; | |
16 | $PERMUTE = 1; | |
17 | $RETURN_IN_ORDER = 2; | |
18 | ||
19 | # Handle POSIX compliancy. | |
20 | if ( defined $ENV{"POSIXLY_CORRECT"} ) { | |
21 | $autoabbrev = 0; # no automatic abbrev of options (???) | |
22 | $getopt_compat = 0; # disallow '+' to start options | |
23 | $option_start = "(--|-)"; | |
24 | $order = $REQUIRE_ORDER; | |
01d0d956 | 25 | $bundling = 0; |
9a24ba61 | 26 | $passthrough = 0; |
ee0007ab | 27 | } |
01e8c204 | 28 | else { |
29 | $autoabbrev = 1; # automatic abbrev of options | |
30 | $getopt_compat = 1; # allow '+' to start options | |
31 | $option_start = "(--|-|\\+)"; | |
32 | $order = $PERMUTE; | |
01d0d956 | 33 | $bundling = 0; |
9a24ba61 | 34 | $passthrough = 0; |
ee0007ab LW |
35 | } |
36 | ||
01e8c204 | 37 | # Other configurable settings. |
38 | $debug = 0; # for debugging | |
39 | $ignorecase = 1; # ignore case when matching options | |
40 | $argv_end = "--"; # don't change this! | |
41 | } | |
352d5a3a | 42 | |
01e8c204 | 43 | use Getopt::Long; |
352d5a3a | 44 | |
01e8c204 | 45 | ################ Subroutines ################ |
352d5a3a | 46 | |
01e8c204 | 47 | sub NGetOpt { |
352d5a3a | 48 | |
01e8c204 | 49 | $Getopt::Long::debug = $newgetopt::debug |
50 | if defined $newgetopt::debug; | |
51 | $Getopt::Long::autoabbrev = $newgetopt::autoabbrev | |
52 | if defined $newgetopt::autoabbrev; | |
53 | $Getopt::Long::getopt_compat = $newgetopt::getopt_compat | |
54 | if defined $newgetopt::getopt_compat; | |
55 | $Getopt::Long::option_start = $newgetopt::option_start | |
56 | if defined $newgetopt::option_start; | |
57 | $Getopt::Long::order = $newgetopt::order | |
58 | if defined $newgetopt::order; | |
01d0d956 | 59 | $Getopt::Long::bundling = $newgetopt::bundling |
60 | if defined $newgetopt::bundling; | |
01e8c204 | 61 | $Getopt::Long::ignorecase = $newgetopt::ignorecase |
62 | if defined $newgetopt::ignorecase; | |
9a24ba61 | 63 | $Getopt::Long::ignorecase = $newgetopt::ignorecase |
64 | if defined $newgetopt::ignorecase; | |
65 | $Getopt::Long::passthrough = $newgetopt::passthrough | |
66 | if defined $newgetopt::passthrough; | |
01e8c204 | 67 | |
68 | &GetOptions; | |
69 | } | |
352d5a3a | 70 | |
01e8c204 | 71 | ################ Package return ################ |
352d5a3a | 72 | |
352d5a3a | 73 | 1; |
01e8c204 | 74 | |
75 | ################ End of newgetopt.pl ################ |