perl - Force use of flags Getopt::Long -
is there way force use of -flags when reading in command-line arguments using getopt::long? example in current situation:
getoptions('r=s' => \$var1, 'lf=f' => \$var2, 'uf=f' => \$var3, 'trd=i' => \$var4, 'vd=f' => \$var5) or die("$usage");
the script not exit or display $usage if arguments still provided without flags (such -lf). instead runs regardless until inevitably errors later on arguments not read respective variables (and may in wrong order).
q: getoptions not return false result when option not supplied
a: that's why they're called 'options'.
source: getopt::long documentation
you add conditionals check value of flags , if not defined call die
or call usage
.
Comments
Post a Comment