On 10-06-17 02:36 AM, Unknown User wrote:
I have the following code:

GetOptions(
        "n|name=s" =>      \$name,
        "a|age=i" =>  \$age,
        "s|sex=s" =>  \$sex,
) || die "Bad options\n";;

GetOptions(
        "name=s" =>        \$name,
        "age=i" => \$age,
        "sex=s" => \$sex,
) || die "Bad options\n";

# GetOptions automatic determines which option by
# the minimum leading letters needed to
# distinguish them.


What i expected this code to do is to die if a bad option was given,
say -s without an arguement, as in ./myprog -n name -s -a 20
However, it does not do that.

What would be the correct method to die if one of the options is not complete?


But they are complete. 'name' is placed in $name, '-a' is placed in $sex, and @ARGV is left with ( '20' ).


--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to