I am trying to manage numerous arguments that are specified by a user when they execute a command. So far, I have been trying to limit my script design to manage arguments as flags that I can easily manage with Getopt::Long as follows:
GetOptions ("a" => \$a, "b" => \$b);
In this way I can check to see if a or b were specified and then execute the respective code/functions.
However, I now have a case where the user can specify two arguments variables as follows:
command -a black -b white
This is fine, but I cannot come up with a good way to determine whether -a or -b is specified first. Therefore I do not know whether the argument variable is assigned to $ARGV[0]
or $ARGV[1]
after I have executed GetOptions ("a" => \$a, "b" => \$b);
.
How can I tell which variable is associated with -a
and which is associated with -b
in the example above?