in reply to -x accepts up to 3 additional arguments
From your description, it sounds like what you want is something closer to
The last line dies if any one of these conditions holds:my ( $x_opt, $y_opt, $z_opt ); my $status = GetOptions( x => \$x_opt, y => \$y_opt, z => \$z_opt, ); die $USAGE if !$status || !@ARGV || ( 1 < grep $_, $x_opt, $y_opt, $z_opt ) || ( $x_opt and @ARGV != 4 ) || ( $y_opt and @ARGV != 3 ) || ( $z_opt and @ARGV != 2 );
Updates: Added remarks to explain the last statement. Changed warn $USAGE and exit 1 to the less flexible but simpler die $USAGE.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getopt::Long making use of $ARGV[n]
by tcf03 (Deacon) on Jun 24, 2005 at 13:00 UTC |