|
Posted by Jim Gibson on September 7, 2005, 10:27 am
Please log in for more thread options
> When using Getopt::Std, if I use:
>
> getopts('c:');
>
> ...and the user specifies the -c flag but fails to specify a parameter
> for the flag, such as:
>
> > myscript -c
>
> ...how do I detect an error? The -c flag is optional but the parameter
> is required if used.
>
> If I just say:
>
> if !($opt_c){
> # this is the same as not using -c at all...
> }
Check the return value of getopts. It will be true (1) if no error
occurred, and false (undef) if there was some error, such as a missing
parameter for an option that needs one.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|