File Coverage

blib/lib/newgetopt.pl
Criterion Covered Total %
statement 13 13 100.0
branch 9 18 50.0
condition n/a
subroutine 2 2 100.0
pod n/a
total 24 33 72.7


line stmt bran cond sub pod time code
1             # Id: newgetopt.pl,v 1.18 2001/09/21 13:34:59 jv
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
11              
12             { package newgetopt;
13              
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;
25             $bundling = 0;
26             $passthrough = 0;
27             }
28             else {
29             $autoabbrev = 1; # automatic abbrev of options
30             $getopt_compat = 1; # allow '+' to start options
31             $option_start = "(--|-|\\+)";
32             $order = $PERMUTE;
33             $bundling = 0;
34             $passthrough = 0;
35             }
36              
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             }
42              
43 1     1   1021 use Getopt::Long;
  1         2  
  1         6  
44              
45             ################ Subroutines ################
46              
47             sub NGetOpt {
48              
49 1 50   1   16 $Getopt::Long::debug = $newgetopt::debug
50             if defined $newgetopt::debug;
51 1 50       3 $Getopt::Long::autoabbrev = $newgetopt::autoabbrev
52             if defined $newgetopt::autoabbrev;
53 1 50       2 $Getopt::Long::getopt_compat = $newgetopt::getopt_compat
54             if defined $newgetopt::getopt_compat;
55 1 50       3 $Getopt::Long::option_start = $newgetopt::option_start
56             if defined $newgetopt::option_start;
57 1 50       2 $Getopt::Long::order = $newgetopt::order
58             if defined $newgetopt::order;
59 1 50       2 $Getopt::Long::bundling = $newgetopt::bundling
60             if defined $newgetopt::bundling;
61 1 50       2 $Getopt::Long::ignorecase = $newgetopt::ignorecase
62             if defined $newgetopt::ignorecase;
63 1 50       2 $Getopt::Long::ignorecase = $newgetopt::ignorecase
64             if defined $newgetopt::ignorecase;
65 1 50       2 $Getopt::Long::passthrough = $newgetopt::passthrough
66             if defined $newgetopt::passthrough;
67              
68 1         13 &GetOptions;
69             }
70              
71             ################ Package return ################
72              
73             1;
74              
75             ################ End of newgetopt.pl ################