I noticed that after using "getopt" at the start of the code reduces $#argv to "0",as a result my below code fails,basically I want to check "if the option f exists then the $#ARGV needs to 7" and "if the option f does not exist the $#ARGV needs to be 5".I tried moving "getopt" code down but the option check fails.Can anyone let me know how can I achieve this?
use Getopt::Std; use Data::Dumper; #Getting the command-line options my %options=(); getopt("fdrv",\%options); #print Dumper( \%options ); #USAGE if (exists $options{f}) { if ($#ARGV !=7) { print "USAGE withouf option f"; } } if (not exists $options{f}) { if ($#ARGV !=5) { print "USAGE without option f"; } }
In reply to How to use getopt and $#argv together? by iphone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |