in reply to command line args - a chicken and egg problem
Hope this helps...Untested code of course :)use vars qw/ $opt_help $opt_one $opt_two $opt_config /; sub parseCommandLine(); parseCommandLine(); ...... ...... sub parseCommandLine() { &getOptions( 'help|h', 'config|c=s', 'one', 'two=s' ) or $opt_help += 1; if( defined( $opt_help ) ) { &printUsage(); exit(0); } if( defined( $opt_config ) ) { &parse_config( $opt_config ); } if( defined( $opt_one )) { # do extra setup required for option 1 } else { $opt_one = 'default_opt_one'; } unless( defined( $opt_two ) ) { $opt_two = 'default_opt_two'; } # Do stuff needed for option 2. } sub parse_config( ) { my $config_file = shift(); # read file # use file to set $opt_one, $opt_two }
|
---|