in reply to How to parse these command-line options?
Note also thatmy $width = 80; sub process { ... } GetOptions ('width=i' => \$width, '<>' => \&process); When applied to the following command line: arg1 --width=72 arg2 --width=60 arg3 This will call "process("arg1")" while "$width" is "80", "process("arg2")" while "$width" is "72", and "process("arg3")" while "$width" is "60".
This feature requires configuration option permute...Also note that using Getopt::Long, you'll probably want to use its syntax for turning off boolean switches, rather than the one you showed.
use Getopt::Long; Getopt::Long::Configure( 'permute' ); my( $a, $b ); GetOptions( 'a!' => \$a, 'b!' => \$b, '<>' => \&process, ); sub process { ... } # call with args like -a foo bar -noa -b baz
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|