Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: using "Getopt::Long" how to check parameter mandatory

by repellent (Priest)
on Aug 25, 2010 at 04:28 UTC ( [id://857072]=note: print w/replies, xml ) Need Help??


in reply to using "Getopt::Long" how to check parameter mandatory

use Getopt::Long qw(GetOptions); Getopt::Long::Configure(qw(posix_default no_ignore_case)); GetOptions(\my %OPT, "mandatory!", ); die "Option --mandatory not specified.\n" unless exists $OPT{mandatory}; print "OK.\n";

On the command line:
$ testcmd.pl Option --mandatory not specified. $ testcmd.pl --manda Unknown option: manda Option --mandatory not specified. $ testcmd.pl --mandatorY Unknown option: mandatorY Option --mandatory not specified. $ testcmd.pl --mandatory OK. $ testcmd.pl --nomandatory OK.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://857072]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2026-04-20 13:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.