Hello, I have a main function which almost works but it it lacks at someplaces.
My script's requirement is that it should run by default without any arguments but if the user wants to run the script with a custom file then he/she should use -c "filename with path"
It would be good if the script could also validate the xml file which is being passed as an argument under elsif condition
Main FunctionHere everything works untill I only runif (@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 { usage (); } } elsif (@ARGV eq 0) { $controlfile = 'network.xml'; parse_xml(); update_exports(); exit 0; }
# perl script.pl -c Use of uninitialized value $ARGV[1] in string at nfs_security.pl line +171. Provided xml file doesnot exists
Here how can I print a warning message along with usage so that when $ARGV1 is not provided throw a warning
In reply to throw a warning if no argument were passed by deep27ak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |