in reply to GetOptions and help

It'ds clearly written into Getopt::Long documentation:
Trouble Shooting GetOptions does not return a false result when an option is not + sup- plied That's why they're called 'options'.

So if you want to make some option mandatory, you'll have to check it by yourself :

usage() unless $res;

Replies are listed 'Best First'.
Re^2: GetOptions and help
by Anonymous Monk on Mar 16, 2006 at 12:31 UTC
    None of the options are mandatory and I don't want them to be. Hence the question still remains . Unless you are suggesting that I have to check for each arguments existence e.g.
    usage() unless $res or $mod or $upd
    This seems an untidy way to do it ?

      If none of the options are mandatory, why would you print usage in the second case?

        I think the OP means "at least one option is mandatory", not "no options are mandatory".



        --chargrill
        $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}
        If I am presented with a program and I don't know what it does or what options are available, I can hazard a guess that there's some kind of help for it. I'd use -h (or perhaps -?) in the first instance and if that didn't work just run the program and see what happens. If nothing is displayed in the second instance I'm none the wiser , hence the requirement to display a help screen .