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"; #### $ 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.