in reply to command line option with- or without argument

Building upon james2vegas's solution and explanation, and satisfying all of your stated requirements:
use strict; use warnings; use Getopt::Long; my $foo; GetOptions ('foo:s', \$foo); if (defined $foo) { $foo = 1 if $foo eq ''; print "foo: $foo\n"; } print "Unprocessed by Getopt::Long\n" if $ARGV[0]; foreach (@ARGV) { print "arg=$_\n"; }