in reply to How to use getopt and $#argv together?
use Getopt::Std; use Data::Dumper; my $arg_num = scalar @ARGV; #Getting the command-line options my %options = (); getopt( "fdrv", \%options ); if ( exists $options{f} ) { if ( $arg_num != 7 ) { print "USAGE withouf option f\n"; } } if ( not exists $options{f} ) { if ( $arg_num != 5 ) { print "USAGE without option f\n"; } }
|
|---|