1 ;# getopts.pl - a better getopt.pl
3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
6 # In particular, this should not be used as an example of modern Perl
7 # programming techniques.
9 # Suggested alternatives: Getopt::Long or Getopt::Std
12 ;# do Getopts('a:bc'); # -a takes arg. -b & -c not. Sets opt_* as a
16 local($argumentative) = @_;
17 local(@args,$_,$first,$rest);
20 @args = split( / */, $argumentative );
21 while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
22 ($first,$rest) = ($1,$2);
23 $pos = index($argumentative,$first);
25 if($args[$pos+1] eq ':') {
28 ++$errs unless(@ARGV);
32 push(\@opt_$first, \$rest);
33 if (!defined \$opt_$first or \$opt_$first eq '') {
34 \$opt_$first = \$rest;
37 \$opt_$first .= ' ' . \$rest;
42 eval "\$opt_$first = 1";
52 print STDERR "Unknown option: $first\n";