| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
;# $RCSfile: getopt.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:58 $ |
|
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
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# In particular, this should not be used as an example of modern Perl |
|
7
|
|
|
|
|
|
|
# programming techniques. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Suggested alternatives: Getopt::Long or Getopt::Std |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
;# Process single-character switches with switch clustering. Pass one argument |
|
12
|
|
|
|
|
|
|
;# which is a string containing all switches that take an argument. For each |
|
13
|
|
|
|
|
|
|
;# switch found, sets $opt_x (where x is the switch name) to the value of the |
|
14
|
|
|
|
|
|
|
;# argument, or 1 if no argument. Switches which take an argument don't care |
|
15
|
|
|
|
|
|
|
;# whether there is a space between the switch and the argument. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
;# Usage: |
|
18
|
|
|
|
|
|
|
;# do Getopt('oDI'); # -o, -D & -I take arg. Sets opt_* as a side effect. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub Getopt { |
|
21
|
3
|
|
|
3
|
|
5153
|
local($argumentative) = @_; |
|
22
|
3
|
|
|
|
|
6
|
local($_,$first,$rest); |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
|
66
|
|
|
30
|
while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { |
|
25
|
9
|
|
|
|
|
33
|
($first,$rest) = ($1,$2); |
|
26
|
9
|
100
|
|
|
|
29
|
if (index($argumentative,$first) >= 0) { |
|
27
|
2
|
100
|
|
|
|
6
|
if ($rest ne '') { |
|
28
|
1
|
|
|
|
|
3
|
shift(@ARGV); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
else { |
|
31
|
1
|
|
|
|
|
2
|
shift(@ARGV); |
|
32
|
1
|
|
|
|
|
3
|
$rest = shift(@ARGV); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
2
|
|
|
|
|
4
|
${"opt_$first"} = $rest; |
|
|
2
|
|
|
|
|
15
|
|
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
else { |
|
37
|
7
|
|
|
|
|
14
|
${"opt_$first"} = 1; |
|
|
7
|
|
|
|
|
24
|
|
|
38
|
7
|
100
|
|
|
|
17
|
if ($rest ne '') { |
|
39
|
2
|
|
|
|
|
16
|
$ARGV[0] = "-$rest"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else { |
|
42
|
5
|
|
|
|
|
38
|
shift(@ARGV); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |