use warnings; use strict; use Getopt::Long qw(GetOptions); my %opt; GetOptions(\%opt, qw(name=s long)) or die; if ( (exists $opt{name}) and ($opt{name} =~ /^-/) ) { die "Option name requires an argument\n"; }