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