http://www.perlmonks.org?node_id=640619


in reply to Trying to understand subtleties of Getopt::Long, please help

What is "mandatory" and "optional" is not the option itself (options are by their nature always optional) but rather the associated argument.

That is, --option without an argument will be an error on option=s or option=i, but will give the empty string on option:s and zero on option:i.

(A missing --option or an option with argument (--option=42) will be treated the same by both.)

Try @ARGV = qw( --tag ); with your cases 5 and 6, and you'll see the behaviour you expected.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!