in reply to Prioritizing command line options
Getopt::Mixed turns the problem on its head, by the fact that you specify a template string for what arguments are to be recognised, and then you repeatedly call a function until it returns no more arguments. Consider:
Getopt::Mixed::init( 'c=s f=s conf>c foo>f'); while( my( $option, $value, $pretty ) = Getopt::Mixed::nextOption() ) +{ OPTION: { $option eq 'c' and do { # you want to do more error checking that this... eval { do $value }; die "Cannot load config file $value: $@\n"; last OPTION; }; $option eq 'f' and do { $Foo = $value; last OPTION; }; # ... } } Getopt::Mixed::cleanup();
In this way, the config file specified by --conf will be done at the point at which it is encountered on the command line.
The only (minor) drawback is that this module is not bundled with the core distribution, you have to download it from CPAN. But it is a pure-perl module and so installs with a minimum of fuss.
--
|
|---|