in reply to Re: Re: More on Processing Command Line Arguments
in thread More on Processing Command Line Arguments
You know, I saw your script and immediately thought about cleaning it up. I didn't even think about reading your question :)
A simple way of ensuring that only one option is used at a time:
GetOptions( 'add=s' =>\my $add, 'edit=s' =>\my $edit, 'list=s' =>\my $list, 'view=s' =>\my $view, 'man' => sub {pod2usage({-verbose => 2, -input => \*DATA}); exi +t}, 'help|?' => sub {pod2usage({-verbose => 1, -input => \*DATA}); exi +t}, ); if (1 == grep { defined } ( $add, $edit, $list, $view )) { print "Good!"; } else { print "Bad!\n"; }
Cheers,
Ovid
New address of my CGI Course.
|
|---|