What I typically do is take all of the variables that are used in the GetOptions function and initialize them first to a value. For optional parameters, I give their corresponding variables a valid default. For the required parameters, I set their variables to something that I consider to be invalid.
Then after calling GetOptions, I do a verification on the variables. Basically if any of the variables now have anything that I consider invalid, I call die and provide an error message. In fact, I usually put the GetOptions and validation in a subroutine and do the initialization outside of that subroutine.
Might not be the best method, but that's how I've handled the issue.
In reply to Re: using "Getopt::Long" how to check parameter mandatory
by dasgar
in thread using "Getopt::Long" how to check parameter mandatory
by shan_emails
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |