in reply to getopt::long treating option as an argument

Thanks for pointing this out! Much of my code uses =s, and I now realize I have bugs. However, upon closer inspection of Getopt::Long, it is documented:
= type [ desttype ] [ repeat ] The option requires an argument of the given type. Supporte +d types are: s String. An arbitrary sequence of characters. It is vali +d for the argument to start with "-" or "--".

Note that it is much less likely (or impossible?) to happen with =i or =f.

For those who store options in a hash, Athanasius' handler approach doesn't apply directly. Here is an equivalent:

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"; }

or, more generally...

my %opt; my @string_opts = qw(name foo|goo bar); GetOptions(\%opt, qw(help long), map { "$_=s" } @string_opts) or die; for my $oname (@string_opts) { $oname = (split /\|/, $oname)[0]; # handle alternate names if ( (exists $opt{$oname}) and ($opt{$oname} =~ /^-/) ) { die "Option $oname requires an argument\n"; } }