in reply to Re: Re: Getopt::Long
in thread Getopt::Long
Of course, I think a better way to do it would be something like the following. (Note: My understanding of perl's refrences lacks something and this should be taken with a grain of salt).if ($command eq 'add' || $command eq 'a') { if (GetOptions(\%hash, 'name=s', 'value=i')) { &doSomething(); } } elsif ($command eq 'edit' || $command eq 'e') { ... }
Cheers,# not tested %commands = ( 'add' => '&add', 'a' => '\$command{add}', 'view' => '&view', 'v' => '\$command{view}', ); while (<STDIN>) { # or whatever $command{$_}; # or is it '\$command{$_}' ? ... } sub add { GetOptions(\%hash, 'name=s', 'value=i'); # your code here } sub view { GetOptions( ... ); # your code here }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Getopt::Long
by hotshot (Prior) on Dec 16, 2002 at 09:25 UTC | |
by ibanix (Hermit) on Dec 16, 2002 at 20:27 UTC |