in reply to throw a warning if no argument were passed
But, as for your script, it seems that the problem is the following:
If (@ARGV > 0), then the number or arguments should really be 2 (you need 0 or 2 arguments, the option and the file name), so that if (@ARGV == 1) (only one argument) it is also an error, but your code is not checking that, hence the problem when you pass the option flag but not the file name.if (@ARGV > 0) { if ( $ARGV[0] eq "-c") { if ( ! -e "$ARGV[1]" ) { print "Provided xml file doesnot exists\n"; } elsif ( -f "$ARGV[1]") { $controlfile = $ARGV[1]; parse_xml(); update_exports(); } } else { #...
In brief, if (@ARGV > 0), then you should check that you have (@ARGV == 2), or else call the usage() sub.
|
|---|