in reply to Re: GetOptions and help
in thread GetOptions and help

I had previously tried doing this but it seems that in my case @ARGV is always -1 regardless of the number of arguments.
Hence if I do this
$numargs = $#ARGV +1; if ($numargs == 0) { usage(); exit(1) }
The usage always kicks in regardless of any options that may have been used

Replies are listed 'Best First'.
Re^3: GetOptions and help
by fishbot_v2 (Chaplain) on Mar 16, 2006 at 16:38 UTC

    GetOptions is destructive: it consumes @ARGV as it processes. You would need to test @ARGV before calling GetOptions.

    I would suggest this instead, though: Just determine what the required arguments are, and test them. In your case, it seems like the required arguments are an alternation:

    unless ( $alt1 or $alt2 or ( $alt3 and $alt4 )) { usage(); exit; }