There are many Perl tutorials that explain how to use the GetOptions utility to process only the command line arguments that are expected, otherwise exit with the appropriate message.
In my requirement, I have the following optional command line arguments, e.g.
- -z zip_dir_path: zip output
- -h: show help.
I tried several combinations with GetOptions that did not work for me.
So my question is: how to use GetOptions to fulfill this requirement?
EDIT: -z needs a zip zip directory path
EDIT2: My script has the following required command line arguments:
- -in input_dir_path: input directory
- -out output_dir_path: Output directory
Here is my code:
my %args; GetOptions(\%args, "in=s", "out=s" ) or die &usage(); die "Missing -in!" unless $args{in}; die "Missing -out!" unless $args{out};
We hope this EDIT adds more clarity.
source share