1N/A;# $RCSfile: getopt.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:58 $
1N/A#
1N/A# This library is no longer being maintained, and is included for backward
1N/A# compatibility with Perl 4 programs which may require it.
1N/A#
1N/A# In particular, this should not be used as an example of modern Perl
1N/A# programming techniques.
1N/A#
1N/A# Suggested alternatives: Getopt::Long or Getopt::Std
1N/A#
1N/A;# Process single-character switches with switch clustering. Pass one argument
1N/A;# which is a string containing all switches that take an argument. For each
1N/A;# switch found, sets $opt_x (where x is the switch name) to the value of the
1N/A;# argument, or 1 if no argument. Switches which take an argument don't care
1N/A;# whether there is a space between the switch and the argument.
1N/A
1N/A;# Usage:
1N/A;# do Getopt('oDI'); # -o, -D & -I take arg. Sets opt_* as a side effect.
1N/A
1N/Asub Getopt {
1N/A local($argumentative) = @_;
1N/A local($_,$first,$rest);
1N/A local($[) = 0;
1N/A
1N/A while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
1N/A ($first,$rest) = ($1,$2);
1N/A if (index($argumentative,$first) >= $[) {
1N/A if ($rest ne '') {
1N/A shift(@ARGV);
1N/A }
1N/A else {
1N/A shift(@ARGV);
1N/A $rest = shift(@ARGV);
1N/A }
1N/A ${"opt_$first"} = $rest;
1N/A }
1N/A else {
1N/A ${"opt_$first"} = 1;
1N/A if ($rest ne '') {
1N/A $ARGV[0] = "-$rest";
1N/A }
1N/A else {
1N/A shift(@ARGV);
1N/A }
1N/A }
1N/A }
1N/A}
1N/A
1N/A1;