in reply to Re: More on Processing Command Line Arguments
in thread More on Processing Command Line Arguments

Thank you it is much cleaner but I still can't get that if statement to work. I will get it just need to sketch it out right.

  • Comment on Re: Re: More on Processing Command Line Arguments

Replies are listed 'Best First'.
Re: Re: Re: More on Processing Command Line Arguments
by Ovid (Cardinal) on Oct 31, 2003 at 17:08 UTC

    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.