Saved has asked for the wisdom of the Perl Monks concerning the following question:
I need help getting the following GetOptions to work. As it is, it fails on the "unless" stating "Missing -arg1! at /usr/local/bin/CheckInput.pl line 11." when I enter Bob 10 10, which I would expect to work. Thanx
#!/usr/bin/perl #<CheckInput.pl> Given a New Testement Reference, Validate it use Getopt::Long; my %args; GetOptions(\%args, "arg1=s", "arg2=i", "arg3=i", ) or die "Invalid arguments!"; die "Missing -arg1!" unless $args{arg1}; die "Missing -arg2!" unless $args{arg2}; die "Missing -arg3!" unless $args{arg3}; print "You entered Valid ARGs\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long and unless
by hdb (Monsignor) on Dec 18, 2013 at 13:06 UTC | |
by Saved (Beadle) on Dec 18, 2013 at 13:15 UTC |